@extends('layouts.base')

@section('content')
    <div class="container-fluid">
        <!-- start page title -->
        <div class="d-flex justify-content-between mt-2 mb-2">
            <h2>
                places
            </h2>
            <ol class="breadcrumb m-0">
                {{-- <li class="breadcrumb-item"><a href="{{ route('apps') }}">ระบบจัดการ</a></li> --}}
                {{-- <li class="breadcrumb-item active">ข้อมูลลูกค้า</li> --}}
            </ol>
        </div>
        <!-- end page title -->

        @if ($message = Session::get('success'))
            <div class="alert alert-success">
                <p>{{ $message }}</p>
            </div>
        @endif

        <div class="card">
            <div class="card-body">
                <!-- command bar -->
                <div class="d-flex justify-content-between">
                    <div>
                        <a class="btn btn-success mb-2" href="{{ route('places.create') }}">
                            <i class="mdi mdi-plus-thick"></i> new place
                        </a>
                    </div>

                </div>
                <!-- end command bar -->
                <table class="table">
                    <thead>
                        <tr class="text-center">
                            {{-- <th>ลำดับ</th> --}}
                            <th>id</th>
                            <th>image_url</th>
                            <th>name_th</th>
                            {{-- <th>address</th> --}}
                            {{-- <th>description</th> --}}

                            {{-- <th>google_place_id</th> --}}
                            {{-- <th>google_url</th> --}}
                            <th>province_id</th>
                            <th>latitude</th>
                            <th>longitude</th>
                            <th>types</th>
                            <th>rating</th>
                            <th>is_trending</th>
                            <th>active</th>
                            <th>command</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse ($places as $index => $place)
                            <tr>
                                {{-- <td class="text-center">{{ $places->firstItem() + $index }}</td> --}}
                                <td class="text-center">
                                    <a href="{{ route('places.show', $place->id) }}">{{ $place->id }}</a>
                                </td>
                                <td><img src="{{ $place->image_url }}" , width="75">
                                <td>{{ $place->name }}</td>
                                {{-- <td>{{ Str::limit($place->address, 64) }}</td> --}}
                                {{-- <td>{{ Str::limit($place->description, 64) }}</td> --}}

                                </td>
                                {{-- <td>{{ $place->google_place_id }}</td> --}}
                                {{-- <td>{{ $place->google_url }}</td> --}}
                                <td class="text-center">
                                    @if ($place->provinces)
                                        {{ $place->provinces->name_th }}
                                    @endif
                                </td>
                                <td class="text-center">{{ $place->latitude }}</td>
                                <td class="text-center">{{ $place->longitude }}</td>
                                <td class="text-center">{{ $place->types }}</td>
                                <td class="text-center">{{ $place->rating }}</td>
                                 <td class="text-center">{{ $place->is_trending }}</td>
                                <td class="text-center">{{ $place->active }}</td>
                                <td class="text-center">
                                        <a href="{{ route('places.show', $place->id) }}" class="btn btn-primary">Show</a> <br>

                                </td>
                            </tr>
                        @empty
                            <tr>
                                <td colspan="14">ไม่มีรายการให้แสดง</td>
                            </tr>
                        @endforelse
                    </tbody>
                </table>
                {{-- {!! $places->links() !!} --}}
                <div class="d-flex justify-content-between">
                    {{-- <div>
                    จำนวนทั้งหมด {{App\Models\Customer::branch()->count()}} รายการ
                </div> --}}
                    <div>
                        {{ $places->links('pagination.paginate') }}
                    </div>
                    <div>
                        หน้าที่ {{ $places->currentPage() }} จาก {{ $places->lastPage() }}
                    </div>
                </div>
            </div>
        </div>
        <!-- end table -->
    </div>
@endsection
