Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many fillable fields in model Laravel?

I have around 200 fields in a table that are numbered:

field_1
field_2
etc

I tried to insert data in table:

Result::insert($data);

Where $data is multiple array:

$data = [] = array("field_1" => 3);
$data = [] = array("field_1" => 2);

Can I set * in option protected $fillable = ["*"]; to make all fields fillable?

like image 395
Griboedov Avatar asked Sep 02 '25 15:09

Griboedov


1 Answers

If you need to set all columns as fillable, do this in the model:

protected $guarded = [];

If you would like to make all attributes mass assignable, you may define the $guarded property as an empty array

https://laravel.com/docs/5.3/eloquent#mass-assignment

like image 63
Alexey Mezenin Avatar answered Sep 05 '25 07:09

Alexey Mezenin