Can eloquent ignore irrelevant data in Laravel 4

后端 未结 4 856
长发绾君心
长发绾君心 2021-01-27 10:33

I have a form that accepts data which will be used to create two new database table entries. The form takes both the users details and their address. The user details will be st

4条回答
  •  無奈伤痛
    2021-01-27 11:12

    Sure enough you can use $fillable array in your model to declare fields allowed for mass-assignment. I believe this is the most sufficient solution in your case.

    class User extends Eloquent {
    
        protected $fillable = [
            'first_name',
            'last_name',
            'email'
        ];
    }
    

提交回复
热议问题