[Laravel 8] Eloquent Modelのfillableとguarded


It is necessary to specify either a fillable or guarded property on your model class. These properties are required because all Eloquent models are protected against mass assignment vulnerabilities by default.

$fillable

To get started, you should define which model attributes you want to make mass assignable. You may do this using the $fillable property on the model.

Models\Student.php
protected $fillable = ['first_name','last_name'];

$guarded

If you would like to make all of your attributes mass assignable, you may define your model's $guarded property as an empty array.

Models\Student.php
protected $guarded = [];

Reference:
https://laravel.com/docs/8.x/eloquent#mass-assignment