Answer the question
In order to leave comments, you need to log in
Why is MassAssignmentException name thrown on create and fill?
In general, I'm trying to insert data into an empty table (too debug option)
public function adminCreate(){
$insertData = [
'calc' => [
'name' => 'Новая печать',
'slug' => 'novaya-pechat'
],
'items' => [
[
'name' => '1',
'img' => 'asd',
'price' => '500 руб'
]
]
];
dd($this->insertCalc($insertData['calc']));
}
public function insertCalc($calcData){
$calc = new Calculators();
$calc->fill($calcData);
$calc->save();
return $calc->id;
}
Answer the question
In order to leave comments, you need to log in
In the Model try to add
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'field_name_1',
'field_name_2',
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question