Hi Readers,
If you are new to Laravel you will definitely come across two properties in the model one is Fillable and another one is Guarded. I myself did not get the use of these properties but once I get along I understood the actual use of these properties. Both these properties can be set at the class or instance level
1) Fillable property:- This property specifies which attributes in the table should be *mass-assignable.
protected $fillable = ['first_name', 'last_name', 'email'];
2) Guarded property:- This property is inverse of fillable and hence do not allow *mass-assignable. The use of this property is to protect the attributes from being mass-assignment.
protected $guarded = ['id', 'password'];
*Mass assignment is a feature allows us to create a record from the values directly.
0 Comment(s)