php - Dynamically create rowspan in laravel
one text
I am newbie in laravel, I'm not trying to show the table like image below the problem of this code is:
I want to create the dynamically rowspan the column Room Type that automatically rowspan while adding more rooms. The outputs need to be like this:
In RoomCalendarController.php
public function index(){
$rooms = Room::all();
return view('admin.room_calendar.view')->with('rooms',$rooms);
}
Below is the view.blade.php file listed code below.
In view.blade.php
<table border="1" cellpadding="5" cellspacing="0">
<th>Room No.</th>
<th>Room Type</th>
@for($i=1; $i<=31; $i++)
<th>{{$i}}</th>
@endfor
<tbody>
@foreach($rooms as $key => $room)
@if($room->room_type == "Single")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td >{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Double")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Triple")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Quad")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Twin")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Cabana")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
@foreach($rooms as $key => $room)
@if($room->room_type == "Connecting Rooms")
<tr data-entry-id="{{ $room->id }}">
<td>{{$room->room_number}}</td>
<td>{{$room->room_type}}</td>
@for($i=1; $i<=31; $i++)
<td></td>
@endfor
</tr>
@endif
@endforeach
</tbody>
</table>
Source