When issuing a mass update via Eloquent, the saving, saved, updating, and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.ui
You may also use the create method to save a new model in a single line. The inserted model instance will be returned to you from the method. However, before doing so, you will need to specify either a fillable or guarded attribute on the model, as all Eloquent models protect against mass-assignment by default.code
protected $fillable = ['name'];
// 可寫入參數
protected $guarded = ['price'];
// 不可寫入參數
在model中選擇上面的一種,注意區別ci