nafeeur10's avatar

How will I use $protected and $guarded in Laravel Properly?

I have a dataset like the below:

data --> come from postman/form
store_id --> come from postman/form
user_id --> not mandatory + come from postman/form
status --> not coming from postman/form but mandatory
protected $fillable = [];

I gave this but it's giving error that status is fillable.

In this case how will I confirm that status, data, store_id is fillable and user_id sometimes fillable?

0 likes
1 reply
Nakov's avatar

You'll have to add them in the array:

protected $fillable = ['data', 'store_id', 'user_id', 'status'];

or use empty $guarded

protected $guarded = [];

but not both.

2 likes

Please or to participate in this conversation.