<form id="form-add-rating">
    <input type="hidden" name="hostel_id" value="{{ $hostel->id }}">
    <table class="table table-hover table-bordered table-striped">
        <thead>
        <tr>
            <th> #</th>
            <th> Ảnh đại diện</th>
            <th> Tên</th>
            <th> Nội dung</th>
            <th> Đánh giá</th>
        </tr>
        </thead>
        <tbody>
        @foreach($renterRooms as $renterRoom)
            @php
                $currentRating = \App\Models\Rating::where('hostel_id', $hostel->id)
                ->where('user_be_rated', $renterRoom->id)->first()
            @endphp
            <tr>
                <input type="hidden" name="user_be_rated[{{ $renterRoom->id }}]" value="{{ $renterRoom->id }}">
                <td> {{ $loop->index + 1 }}</td>
                @if(!empty($renterRoom->image))
                    <td><img style="max-width: 100px" class="img-circle" src="/files/{{ $renterRoom->image }}"/></td>
                @else
                    <td><img style="max-width: 100px" class="img-circle" src="/frontend3/assets/img/placeholder.png"/>
                    </td>
                @endif
                <td> @if(!empty($renterRoom->name)) {{ $renterRoom->name }} @else {{ $renterRoom->first_name .' '.$renterRoom->last_name }} @endif</td>
                <td>
                    <textarea class="form-control" name="content[{{ $renterRoom->id }}]">@if(!empty($currentRating)){{ $currentRating->content }}@endif</textarea>
                </td>
                <td>
                    <select class="bar-rating" name="rate[{{ $renterRoom->id }}]">
                        <option @if(!empty($currentRating)) @if($currentRating->rate == 1) selected="" @endif @endif value="1">1</option>
                        <option @if(!empty($currentRating)) @if($currentRating->rate == 2) selected="" @endif @endif value="2">2</option>
                        <option @if(!empty($currentRating)) @if($currentRating->rate == 3) selected="" @endif @endif value="3">3</option>
                        <option @if(!empty($currentRating)) @if($currentRating->rate == 4) selected="" @endif @endif value="4">4</option>
                        <option @if(!empty($currentRating)) @if($currentRating->rate == 5) selected="" @endif @endif value="5">5</option>
                    </select>

                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</form>