Object of class App\Bed could not be converted to int
when i add no of beds then my bed table insert no of times entry so how can do it
here is my code
public function store(Request $request)
{
$pgdetails = new Pgdetail(array(
'room'=>$request->get('room'),
'bed_type'=>$request->get('bed_type'),
'no_of_beds'=>$request->get('no_of_beds'),
));
$pgdetails->save();
$id = $pgdetails->id;
$beds = $pgdetails->no_of_beds;
for($no=0;$no<$beds;$no++){
$beds = New Bed(array(
'room_id'=>$id,
'bed'=>$no,
'status'=>'assign'
));
$beds->save();
}
return back();
}
Just saw the error. You are reusing a variable name for two different things
Remove the s
$bed = New Bed(array(
'room_id'=>$id,
'bed'=>$no,
'status'=>'assign'
));
$bed->save();
Please or to participate in this conversation.