mehany

MassAssignmentException and $guarded is set to []

Posted 2 years ago by mehany

I have a model with two attributes name and description . I get MassAssignmentException while I have $guarded property set to [] am I missing something?

here is my model

class MyModal extends Model
{

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'description'];

    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    protected $guarded = [];

}

In my controller I do

    public function store(Request $request)
    {
        //
        $item = MyModal::create($request->input());

    }

Laravel Framework version 5.3.29

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.