I don't know how your data looks, but by looking at your code columns and availble_times are date fields. If Times model is dictionary for hours (like 1. 8.00, 2. 8:45, 3. 9:00) , and booking hour has to be in Times records, then you just need to invert the loops to display each time for each bookingbooking_time
@foreach($bookings as $booking)
@foreach($times as $time)
<tr>
<td>{{ getImaginedChairNumber() }}</td>
<td>{{ $time->availble_times }}</td>
@if($time->availble_times == $booking->booking_time)
{{-- There is already booking for that dictionary time --}}
<td>not available</td>
@else
<td>available</td>
@endif
</tr>
@endforeach
@endforeach
Should produce similar table:
╔═══════╦══════╦═══════════════╗
║ Chair ║ Time ║ Booking ║
╠═══════╬══════╬═══════════════╣
║ A1 ║ 8:00 ║ not available ║
║ A1 ║ 8:45 ║ available ║
║ A1 ║ 9:00 ║ not available ║
║ A2 ║ 8:00 ║ not available ║
║ A2 ║ 8:45 ║ not available ║
║ A2 ║ 9:00 ║ not available ║
║ A3 ║ 8:00 ║ available ║
║ A3 ║ 8:45 ║ available ║
║ A3 ║ 9:00 ║ not available ║
╚═══════╩══════╩═══════════════╝
Is this the correct form of the output table you expect? (I used this tool to draw ascii table https://senseful.github.io/web-tools/text-table/)
You are overwriting the variable values of you take that each result in the array.$robjeks
You may try like
$temps = DB::table('t_hasil_temp')
->where('id_wi', $idwisa)
->get();
foreach ($temps as $value) {
$stemp = DB::table('t_hasil_temp')
->where('id', $value->id)
->first();
$temp = explode(",",$stemp->hasil);
$tempStr = implode(',', $temp);
$robjeks[] = DB::table('objek')->whereIn('id', $temp)->orderByRaw(DB::raw("field(id, $tempStr)"))->get();
}
You view should like
@foreach($temps as $tem)
<ul id="list">
@foreach($robjeks as $robjek)
@if($tem->id == $robjek->id)
<li class="list_item {{$robjek->kategori}}">
.....
</li>
@endif
@endforeach
</ul>
@endforeach
In your @foreach, you can create the new records.
use App\Models\VideoHistory;
$videoHistory = VideoHistory::create([
'create_time' => $videohistory->create_time,
'end_time' => $videohistory->end_time,
'begin_time' => $videohistory->begin_time,
]);
As an alternative to Alexey Mezenin's answer you could use instead. http://php.net/manual/en/function.array-chunk.phparray_chunk
@foreach(array_chunk($address, 2) as $chunk)
<div class="row">
@foreach($chunk as $add)
<div class="col-md-6">
Some data
</div>
@endforeach
</div>
@endforeach
I personally find the the above a little more readable.
Alternatively, if is a collection you could do $address instead of $address->chunk(2).array_chunk($address, 2)
If you want to change the amount of columns you have you would simply need to change the to be however many columns you want.2