I have an array like this :
array:4 [▼
"*name1*" => 1
"*name2*" => 1
"*name3*" => 2
"*name4*" => 1
]
And I have an table Item with 'id'; 'name'; 'time'
Then how to I can save this array into Item Table using Laravel ?
I already do this but I know it's not working. But I don't know how to save it
foreach ($data_participant[$i]['attributes']['stats']['itemGrants'] as $key => $value) {
$itemGrants = new ItemGrant;
$itemGrants->item = $key;
$itemGrants->time = $value;
$itemGrants->save();
}
$data_participant[$i]['attributes']['stats']['itemGrants']might be empty ?ItemGrantis an eloquent model?If yes, which table is represented by the model?