@extends('layouts.app')
@section('title')编辑-城市@endsection

@section('content')
    <div id="nav2">
        @component('maintenance.menu')
        @endcomponent
        @component('maintenance.city.menu')
                <li class="nav-item">
                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
                </li>
        @endcomponent
    </div>
    <div class="container-fluid">
        <div class="card">
            <div class="card-body">
                <form method="POST" action='{{url("maintenance/city/{$city->id}")}}'>
                    @csrf
                    @method('PUT')
                    <div class="form-group row">
                        <label for="province_id" class="col-2 col-form-label text-right">所属省份</label>
                        <div class="col-sm-8 col-md-4 col-lg-3 ">
                            <select name="City[province_id]" class="form-control ">
                                @foreach($provinces as $province)
                                    @if($city->province_id==$province->id)
                                        <option value="{{$province->id}}" selected>{{$province->name}}</option>
                                    @else
                                        <option value="{{$province->id}}">{{$province->name}}</option>
                                    @endif
                                @endforeach
                            </select>
                            @error('name')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="name" class="col-2 col-form-label text-right">城市名称</label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('City.name') is-invalid @enderror"
                                   name="City[name]" autocomplete="off" value="{{old('City')['name']?old('city')['name']:$city->name}}" required>
                            @error('City.name')
                            <span class="invalid-feedback" role="alert">
                                 <strong>{{ $errors->first('City.name') }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-8 offset-2">
                            <input type="submit" class="btn btn-outline-dark form-control">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
