@extends('layouts.app')

@section('title', 'Edit Shipper')

@section('content')

<div class="container-fluid">

    <!-- Page Heading -->
    <div class="d-sm-flex align-items-center justify-content-between mb-4">
        <h1 class="h3 mb-0 text-gray-800">Edit Shipper</h1>
        <a href="{{route('shipperlist.index')}}" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
                class="fas fa-arrow-left fa-sm text-white-50"></i> Back</a>
    </div>

    {{-- Alert Messages --}}
    @include('common.alert')
   
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">Edit Shipper Personal Details</h6>
        </div>
        <form method="POST" action="{{route('shipperlist.updateshipperDetails', ['id' => $shippers->id])}}">
            @csrf
            @method('PUT')

            <div class="card-body">
                <div class="form-group row">

{{-- shipper --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Shipper</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('shipper') is-invalid @enderror" 
                            id="shipper"
                            placeholder="shipper" 
                            name="shipper" 
                           
                            value="{{ old('shipper') ?  old('shipper') : $shippers->shipper}}">
                        @error('shipper')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- EMAIL --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Email</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('email') is-invalid @enderror" 
                            id="email"
                            placeholder="email" 
                            name="email" 
                            value="{{ old('email') ?  old('email') : $shippers->email}}">

                        @error('email')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- Mobile Number --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Mobile Number</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('mobile_number') is-invalid @enderror" 
                            id="mobile_number"
                            placeholder="mobile_number" 
                            name="mobile_number" 
                            value="{{ old('mobile_number') ?  old('mobile_number') : $shippers->mobile_number}}">

                        @error('mobile_number')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                   
                    {{-- fixed_number --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Fixed Number</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('fixed_number') is-invalid @enderror" 
                            id="fixed_number"
                            placeholder="fixed_number" 
                            name="fixed_number" 
                            value="{{ old('fixed_number') ?  old('fixed_number') : $shippers->fixed_number}}">

                        @error('fixed_number')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- street --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>street</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('street') is-invalid @enderror" 
                            id="street"
                            placeholder="street" 
                            name="street" 
                            value="{{ old('street') ?  old('street') : $shippers->street}}">

                        @error('street')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- building --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Building</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('building') is-invalid @enderror" 
                            id="building"
                            placeholder="building" 
                            name="building" 
                            value="{{ old('building') ?  old('building') : $shippers->building}}">
                        @error('building')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- city --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>city</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('city') is-invalid @enderror" 
                            id="city"
                            placeholder="city" 
                            name="city" 
                            value="{{ old('city') ?  old('city') : $shippers->city}}">

                        @error('city')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                   
                    {{-- state --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>State</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('state') is-invalid @enderror" 
                            id="state"
                            placeholder="state" 
                            name="state" 
                            value="{{ old('state') ?  old('state') : $shippers->state}}">

                        @error('state')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- postalcode --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>postalcode</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('postalcode') is-invalid @enderror" 
                            id="postalcode"
                            placeholder="postalcode" 
                            name="postalcode" 
                            value="{{ old('postalcode') ?  old('postalcode') : $shippers->postalcode}}">

                        @error('postalcode')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- country --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>country</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('country') is-invalid @enderror" 
                            id="country"
                            placeholder="country" 
                            name="country" 
                            value="{{ old('country') ?  old('country') : $shippers->country}}">

                        @error('country')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- type --}}
                    <div class="col-sm-6 mb-3  mb-sm-0">
                        <span style="color:red;">*</span>Type</label>
                        <select class="form-control form-control-user @error('type') is-invalid @enderror" name="type">
                            <option selected disabled>Select type</option>
                            <option value="1" {{old('type') ? ((old('type') == 1) ? 'selected' : '') : (($shippers->type == 1) ? 'selected' : '')}}>National_Services</option>
                            <option value="2" {{old('type') ? ((old('type') == 2) ? 'selected' : '') : (($shippers->type == 2) ? 'selected' : '')}}>International_Services</option>
                            </select>
                        @error('type')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    {{-- descriptions --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Descriptions</label>
                        <input 
                            type="text" 
                            class="form-control form-control-user @error('descriptions') is-invalid @enderror" 
                            id="descriptions"
                            placeholder="descriptions" 
                            name="descriptions" 
                            value="{{ old('descriptions') ?  old('descriptions') : $shippers->descriptions}}">

                        @error('descriptions')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
                    
                    {{-- Status --}}
                    <div class="col-sm-6 mb-3 mb-sm-0">
                        <span style="color:red;">*</span>Status</label>
                        <select class="form-control form-control-user @error('status') is-invalid @enderror" name="status">
                            <option selected disabled>Select Status</option>
                            <option value="1" {{old('status') ? ((old('status') == 1) ? 'selected' : '') : (($shippers->status == 1) ? 'selected' : '')}}>Active</option>
                            <option value="0" {{old('status') ? ((old('status') == 0) ? 'selected' : '') : (($shippers->status == 0) ? 'selected' : '')}}>Inactive</option>
                        </select>
                        @error('status')
                            <span class="text-danger">{{$message}}</span>
                        @enderror
                    </div>
</div>
            <div class="card-footer">
                <button type="submit" class="btn btn-success btn-user float-right mb-3">Update</button>
                <a class="btn btn-primary float-right mr-3 mb-3" href="{{ route('shipperlist.index') }}">Cancel</a>
            </div>
            
        </form>
    </div>
    </div>
</div>


@endsection