Error Field doesn’t have a default value in laravel 5.3

You should add ->nullable() or ->default(‘somethingHere’) to fields which you send empty values. $table->string(‘family’)->nullable(); //this means that if you send empty value this field will become MySQL NULL Or set default value: $table->string(‘family’)->default(‘default value here’); Than remigrate: php artisan migrate:rollback and php artisan migrate

Laravel extend Form class

To extend/swap a Laravel core class, you can create a Service Provider: File: app/App/Libraries/Extensions/FormBuilder/FormBuilderServiceProvider.php <?php namespace App\Libraries\Extensions\FormBuilder; use Illuminate\Support\ServiceProvider as IlluminateServiceProvider; use App\Libraries\Extensions\FormBuilder\FormBuilder; class FormBuilderServiceProvider extends IlluminateServiceProvider { /** * Indicates if loading of the provider is deferred. * * @var bool */ protected $defer = true; /** * Register the service provider. * * … Read more

Laravel Eloquent – Where In All

You’ll have to add multiple whereHas for that: $query = User::with(‘activities’); foreach($selectedActivities as $activityId){ $query->whereHas(‘activities’, function($q) use ($activityId){ $q->where(‘id’, $activityId); }); } $userByActivities = $query->get();

How to create a database-driven multi-level navigation menu using Laravel

So after doing much more searching and reading from different sources this is what I came up with and it’s working fine: /app/models/Navigation.php <?php class Navigation extends Eloquent { /** * The database table used by the model. * * @var string */ protected $table=”navigation”; public function parent() { return $this->hasOne(‘navigation’, ‘id’, ‘parent_id’); } public … Read more

Laravel Form methods VS traditional coding

Using built-in HTML helpers have many benefits: Using Form::open you add CSRF protection input hidden (by default) Using form elements (inputs/textarea etc.) and withInput method for Redirection allows you to easily fill in the form with the same data with almost no coding If you use Redirect::route(‘form’->withInput(); and have input text {{Form::text(‘username’)}} it will automatically … Read more