class Student extends Model {
protected $fillable = [‘first_name’, ‘last_name’, ‘email’];
}
Source: https://medium.com/@kshitij206/laravel-mass-assignment-guarded-or-fillable-7c3a64b49ca6
Everywhere on the Internet, they say to use fillable or guarded for security in Laravel.
But if a field is fillable, then, can this field be hacked?
All Eloquent models are protected against mass-assignment by default, so to use mass assignment, you should specify a
fillableorguardedattribute on the model to use thecreatemethod to save a new model in a single line.So the code below, should cause an error
when you have
Because you cannot mass assign the
numberproperty here.Read more here: https://laravel.com/docs/7.x/eloquent#mass-assignment