Issue
In each Laravel model, I want to declare fillable like the following.
protected $fillable = [
'object_name','attributes','item','cost','status','category',
'object_id','status','customer_id','provider_id'
];
After that, I can insert value in the database. Is there any way to make all columns of every newly created table fillable, or will I need to change it every time?
Solution
you can use guarded property in model class;
protected $guarded = [];
after adding this line you don't need to define fillable array in model class. so remove that property
$fillable serves as a "white list" whereas $guarded serves like a "black list". One should use either $fillable or $guarded.
Answered By - Akash Kumar Verma
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.