Live,
I'm using laravel 5.1 and after submitting a form that has a collection of checkboxes
array:3 [▼
0 => "24"
1 => "26"
2 => "32"
]
I write the record and then in a related table I insert the record block
if( $auto->save() )
{
$extras = $request['extra'];
foreach( $extras as $extra)
{
$extra = new AutoExtras;
$extra->auto_id = $auto->id;
$extra->extra_id = $extra;
$extra->save();
}
}
This would be supposed to work however, it creates the first record by putting the extra_id = 0 and gives the following error:
ErrorException in helpers.php line 685: Method App \ AutoExtras :: __ toString () must return a string value
What is the problem?