Thanks iridion9.
As he said this is now automatically added out of the box, then after watching this video do you only need to assign $fillable if it is throwing an mass assignment exception error?
Mass assignment is enabled out of the box. If you plan on setting multiple fields through your application you need to set either the $fillable or $guarded value in your Model. For instance if you are allowing users to join your site your probably have a form with multiple input fields. Since you will be taking the data and storing it to your database, these fields must be $fillable. Keep in mind the values or fields that you have in your form input are likely not ALL the fields on your table. So a typical user table has an id field and timestamps which is never set directly by the ui.
Fillable only really applies to mass assignment and that is only comes into play when you are creating/updating an Eloquent model. Reading your question it does not apply to requesting attributes. Some examples where using fillable is advised:
// Here we are creating a new article instance and just want to pass the fields from the input array
$article = new Article(Input::all());
$article->save();
// Here we are creating the article and persisting it
$article = Article::create(Input::all());
The docs are also nice and clear.
I found a Laracast here that Jefferey explains this quite well
[https://laracasts.com/series/laravel-5-fundamentals/episodes/8]
now before posting any data from form to the live to the database you should specify in the laravel model that the columns name you can fill by the post data for e.g protected $fillable = ['title', 'description', 'status','user_id','accepted'];
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community