@extends('layouts.base')

@section('content')
    <div class="container-fluid">
        <!-- start page title -->
        <div class="d-flex justify-content-between mt-2 mb-2">
            <h2>
                Edit Place
            </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 ($errors->any())
            <div class="alert alert-danger">
                <strong>Whoops!</strong> There were some problems with your input.<br><br>
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif
        <div class="card">
            <div class="card-body">
                <!-- command bar -->
                <div class="d-flex justify-content-between">
                    <div>
                        <a href="javascript:history.back()" class="btn btn-primary mb-2">
                            กลับ
                        </a>
                    </div>
                </div>
                <!-- end command bar -->
                <form action="{{ route('places.update', $place->id) }}" method="POST" enctype="multipart/form-data">
                    @csrf
                    @method('PUT')

                    <div class="row">
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>name</strong>
                                <input type="text" name="name" value="{{ $place->name }}" class="form-control"
                                    placeholder="Enter Name">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>address</strong>
                                <input type="text" name="address" value="{{ $place->address }}" class="form-control"
                                    placeholder="Enter Address">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>description</strong>
                                <textarea class="form-control" name="description"
                                    placeholder="Enter Description">{{ $place->description }}</textarea>
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12">
                            <div class="form-group">
                                <strong>Image:</strong>
                                <input type="file" name="image" class="form-control" placeholder="Post Image">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>image_url</strong>
                                <input type="text" name="image_url" value="{{ $place->image_url }}" class="form-control"
                                    placeholder="Enter Image Url">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>google_place_id</strong>
                                <input type="text" name="google_place_id" value="{{ $place->google_place_id }}"
                                    class="form-control" placeholder="Enter Google Place Id">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>google_url</strong>
                                <input type="text" name="google_url" value="{{ $place->google_url }}"
                                    class="form-control" placeholder="Enter Google Url">
                            </div>
                        </div>
                        {{-- <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>province_id</strong>
                                <input type="number" name="province_id" value="{{ $place->province_id }}"
                                    class="form-control" placeholder="Enter Province Id">
                            </div>
                        </div> --}}
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>province</strong>
                                <select class="form-select" name="province_id">
                                    <option>เลือกจังหวัด</option>
                                    @foreach ($provinces as $province)
                                        <option value="{{ $province->id }}"
                                            @if ($province->id == $place->province_id) selected @endif>
                                            {{ $province->name_th }}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>latitude</strong>
                                <input type="numeric" name="latitude" value="{{ $place->latitude }}"
                                    class="form-control" placeholder="Enter Latitude">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>longitude</strong>
                                <input type="numeric" name="longitude" value="{{ $place->longitude }}"
                                    class="form-control" placeholder="Enter Longitude">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            <div class="form-group">
                                <strong>types</strong>
                                <input type="text" name="types" value="{{ $place->types }}" class="form-control"
                                    placeholder="Enter Types">
                            </div>
                        </div>
                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            is_trending <br>
                            <input type="radio" id="is_trending" name="is_trending" value="1"
                                {{ $place->is_trending == '1' ? 'checked' : '' }}> Active</label>

                            <input type="radio" id="is_trending" name="is_trending" value="0"
                                {{ $place->is_trending == '0' ? 'checked' : '' }}> Inactive</label>

                        </div>

                        <div class="col-xs-12 col-sm-12 col-md-12 mb-2">
                            active <br>
                            <input type="radio" id="active" name="active" value="1"
                                {{ $place->active == '1' ? 'checked' : '' }}> Active</label>

                            <input type="radio" id="active" name="active" value="0"
                                {{ $place->active == '0' ? 'checked' : '' }}> Inactive</label>

                        </div>

                        <div class="col-xs-12 col-sm-12 col-md-12 text-center">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </div>


                </form>
            </div>
        </div>

    </div>
@endsection
