HEX
Server: LiteSpeed
System: Linux us-phx-web629.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64
User: u756937133 (756937133)
PHP: 8.2.27
Disabled: passthru,chgrp
Upload Files
File: /home/u756937133/domains/swingersnest.com/public_html/resources/views/admin/cities/edit.blade.php
@extends('layouts.admin')

@section('title', 'Edit City - Admin Panel')
@section('page-title', 'Edit City')

@section('content')
    <div class="pt-[14px] pb-8">
        <div class="mb-6">
            <a href="{{ route('admin.cities.index') }}" class="text-[#717182] hover:text-[#FF8FA3] flex items-center gap-2">
                <i class="ri-arrow-left-line"></i>
                <span>Back to Cities</span>
            </a>
        </div>

        <h2 class="text-[#0A0A0A] text-[24px] font-medium font-['poppins'] mb-2">Edit City</h2>
        <p class="text-[#717182] font-['poppins'] mb-6">Update city information</p>

        @if($errors->any())
            <div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded-xl">
                <ul class="list-disc space-y-1 pl-5">
                    @foreach($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

        <div class="bg-white rounded-xl shadow-sm border border-[#0000001A] p-6 md:p-8">
            <form method="POST" action="{{ route('admin.cities.update', $city) }}" class="space-y-6">
                @csrf
                @method('PUT')

                <div>
                    <label for="country_id" class="block text-sm font-medium text-gray-700 mb-2">
                        Country
                    </label>
                    <select
                        id="country_id"
                        name="country_id"
                        class="w-full px-4 py-2 border border-[#0000001A] rounded-xl focus:outline-none focus:ring-2 focus:ring-[#FF8FA3]"
                    >
                        <option value="">Select Country</option>
                        @foreach($countries as $country)
                            <option value="{{ $country->id }}" {{ old('country_id', $city->state->country_id) == $country->id ? 'selected' : '' }}>
                                {{ $country->name }}
                            </option>
                        @endforeach
                    </select>
                    <p class="mt-1 text-xs text-gray-500">Select country to filter states</p>
                </div>

                <div>
                    <label for="state_id" class="block text-sm font-medium text-gray-700 mb-2">
                        State/Province <span class="text-red-500">*</span>
                    </label>
                    <select
                        id="state_id"
                        name="state_id"
                        required
                        class="w-full px-4 py-2 border border-[#0000001A] rounded-xl focus:outline-none focus:ring-2 focus:ring-[#FF8FA3]"
                    >
                        <option value="">Select State</option>
                        @foreach($states as $state)
                            <option value="{{ $state->id }}" {{ old('state_id', $city->state_id) == $state->id ? 'selected' : '' }}>{{ $state->name }}</option>
                        @endforeach
                    </select>
                </div>

                <div>
                    <label for="name" class="block text-sm font-medium text-gray-700 mb-2">
                        City Name <span class="text-red-500">*</span>
                    </label>
                    <input
                        type="text"
                        id="name"
                        name="name"
                        value="{{ old('name', $city->name) }}"
                        required
                        class="w-full px-4 py-2 border border-[#0000001A] rounded-xl focus:outline-none focus:ring-2 focus:ring-[#FF8FA3]"
                        placeholder="e.g., Los Angeles"
                    >
                </div>

                <div class="flex items-center">
                    <input
                        type="checkbox"
                        id="is_active"
                        name="is_active"
                        value="1"
                        {{ old('is_active', $city->is_active) ? 'checked' : '' }}
                        class="w-4 h-4 text-[#FF8FA3] border-gray-300 rounded focus:ring-[#FF8FA3]"
                    >
                    <label for="is_active" class="ml-2 text-sm font-medium text-gray-700">
                        Active (City will be available for selection)
                    </label>
                </div>

                <div class="flex gap-4 pt-4">
                    <button type="submit" class="px-6 py-2.5 bg-[#FF8FA3] text-white rounded-xl hover:bg-[#FF6F61] transition font-semibold">
                        Update City
                    </button>
                    <a href="{{ route('admin.cities.index') }}" class="px-6 py-2.5 bg-gray-200 text-gray-700 rounded-xl hover:bg-gray-300 transition font-semibold">
                        Cancel
                    </a>
                </div>
            </form>
        </div>
    </div>

    <script>
        // Update states dropdown when country changes
        document.getElementById('country_id')?.addEventListener('change', function() {
            const countryId = this.value;
            const stateSelect = document.getElementById('state_id');
            
            if (countryId) {
                // Fetch states for selected country
                fetch(`/admin/states-by-country/${countryId}`)
                    .then(response => response.json())
                    .then(states => {
                        const currentStateId = {{ $city->state_id }};
                        stateSelect.innerHTML = '<option value="">Select State</option>';
                        states.forEach(state => {
                            const selected = state.id == currentStateId ? 'selected' : '';
                            stateSelect.innerHTML += `<option value="${state.id}" ${selected}>${state.name}</option>`;
                        });
                    })
                    .catch(error => console.error('Error:', error));
            } else {
                stateSelect.innerHTML = '<option value="">Select State</option>';
            }
        });
    </script>
@endsection