Laravel 5 Mass Assignment, Guarded or Fillable?

What is Fillable?

fillable lets you specify which fields is mass-assignable in your model. Lets take the above example, you can do it by adding the special variable $fillable to the model. So in the model:

As you have noticed, the ‘id, student_type‘ are not included, which means they are exempted.

Note: When ever you alter your table and add new field to it, don’t forget to add it into the $fillable variable if it is included in the white-list. “I experienced having trouble figuring out why the new field of my table is not saving, and just found out, I forgot to add it in the $fillable variable. I felt pity on my self that time. LOL.”

Sharing is caring!