Closed robsontenorio closed 6 years ago
If you have fillable fields, then Laravel should filter out automatically all the properties that are not fillable. Am I wrong?
@deiucanta
It only removes attributes from the Model that originally did not belong to the Model.
If you use fillable ()
you are safe, because fill()
method will be handle it, ignoring all the other attributes that does not belongs to the Model.
But if you use the inverse logic with guarded()
, then some garbage will go directly to the model as an attribute when you use fill()
. When you try to save an exception it will be thrown, because such a field does not exist in the DB.
Why not remove extra attributes from model when saving? It happens just before validation().
Save a lot of time when you use the
fill()
method from Controllers!