Laravel中插入数据显示“Add [cate_name] to fillable property to allow mass ”

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.

解决方法:

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.

protected $fillable = ['name']; // 可写入参数
protected $guarded = ['price']; // 不可写入参数
在model中选择上面的一种,注意区别

你可能感兴趣的:(Laravel中插入数据显示“Add [cate_name] to fillable property to allow mass ”)