Hi i have this select checkbox which is the time when i check all the value does pass through it! Now my problem is when i saved into the database it is only one value saved. this is my HTML
<p>Sunday</p>
<input type="checkbox" name="select-all-sunday" id="select-all-sunday" onclick="toggle(this);"> Check All
<br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-1" value="00:00"> 00:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-2" value="1:00"> 1:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-3" value="2:00"> 2:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-4" value="3:00"> 3:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-5" value="4:00"> 4:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-6" value="5:00"> 5:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-7" value="6:00"> 6:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-8" value="7:00"> 7:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-9" value="8:00"> 8:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-10" value="9:00"> 9:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-11" value="10:00"> 10:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-12" value="11:00"> 11:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-13" value="12:00"> 12:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-14" value="13:00"> 13:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-15" value="14:00"> 14:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-16" value="15:00"> 15:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-17" value="16:00"> 16:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-18" value="17:00"> 17:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-19" value="18:00"> 18:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-20" value="19:00"> 19:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-21" value="20:00"> 20:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-22" value="21:00"> 21:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-23" value="22:00"> 22:00 <br>
<input type="checkbox" name="checkbox-sunday[]" id="checkbox-24" value="23:00"> 23:00 <br>
this is now my controller
$sundays = $request->input('checkbox-sunday');
foreach($sundays as $sunday){
echo $sunday.",";
}
Now the echo $sunday seems the value being passed from the form display correctly. Now upon saving into the database only one value is being saved.
Below is my code upon saving to the database
$sundays = $request->input('checkbox-sunday');
foreach($sundays as $sunday){
echo $sunday.",";
$postRoom = PostRoom::find($id);
$postRoom->description = $request->get('description');
$postRoom->checkin_date = $request->get('bookingDate');
$postRoom->checkin_time = $request->get('checkinTime');
$postRoom->room_price = $request->get('roomPrice');
$postRoom->day_sunday = $sunday;
$postRoom->your_neighbourhood = $request->get('yourNeighbourhood');
$postRoom->save();
return redirect('add-your-listing/next-step-3/'.$postRoom->id);
}
what is the best way to saved this one?. Can someone help me? TIA.
$idfrom?