How I can change the fillable attribute of a model on the fly?
For example, I have User model with, protected $fillable = ['name', 'email', 'password']
When updating the user, I want to exclude 'email' from mass assignment so that the email is not changed on update.
Mass assignment doesn't mean all the field listed in
fillable
will be auto filled.You still have control over what to save in the table.
So if you do:
Only email will be saved in the example above while name and password remains the same