feat: add province and city management

This commit is contained in:
2026-08-22 11:25:31 +03:30
parent 07e6dc7f5d
commit 64bfa2b94f
10 changed files with 408 additions and 0 deletions
@@ -0,0 +1,34 @@
@extends('admin.layouts.app')
@section('title', 'افزودن شهر')
@section('content')
<div class="admin-card p-4">
<h5 class="mb-4">افزودن شهر جدید</h5>
<form action="{{ route('admin.locations.cities.store') }}" method="POST">
@csrf
<div class="mb-3">
<label class="form-label">نام شهر</label>
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
value="{{ old('name') }}">
@error('name')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="mb-3">
<label class="form-label">استان</label>
<select name="province_id" class="form-control @error('province_id') is-invalid @enderror">
<option value="">انتخاب استان...</option>
@foreach($provinces as $province)
<option
value="{{ $province->id }}" {{ old('province_id') == $province->id ? 'selected' : '' }}>{{ $province->name }}</option>
@endforeach
</select>
@error('province_id')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<button type="submit" class="btn btn-success">ذخیره اطلاعات</button>
<a href="{{ route('admin.locations.cities.index') }}" class="btn btn-secondary">انصراف</a>
</form>
</div>
@endsection
@@ -0,0 +1,31 @@
@extends('admin.layouts.app')
@section('content')
<div class="card">
<div class="card-header"><h5>ویرایش شهر: {{ $city->name }}</h5></div>
<div class="card-body">
<form action="{{ route('admin.locations.cities.update', $city->id) }}" method="POST">
@csrf @method('PUT')
<div class="form-group">
<label>نام شهر</label>
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
value="{{ old('name', $city->name) }}">
@error('name') <span class="text-danger">{{ $message }}</span> @enderror
</div>
<div class="form-group">
<label>استان مربوطه</label>
<select name="province_id" class="form-control @error('province_id') is-invalid @enderror">
@foreach($provinces as $province)
<option
value="{{ $province->id }}" {{ old('province_id', $city->province_id) == $province->id ? 'selected' : '' }}>
{{ $province->name }}
</option>
@endforeach
</select>
@error('province_id') <span class="text-danger">{{ $message }}</span> @enderror
</div>
<button type="submit" class="btn btn-primary">بروزرسانی</button>
</form>
</div>
</div>
@endsection
@@ -0,0 +1,69 @@
@extends('admin.layouts.app')
@section('title', 'مدیریت شهرها')
@section('breadcrumb')
<div>
<h1 class="page-title fw-medium fs-18 mb-2">مدیریت شهرها</h1>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard.index') }}">داشبورد</a></li>
<li class="breadcrumb-item active">مدیریت مناطق / شهرها</li>
</ol>
</nav>
</div>
@endsection
@section('content')
<div class="container-fluid pt-4">
<div class="card custom-card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">لیست شهرها</h5>
<a href="{{ route('admin.locations.cities.create') }}" class="btn btn-primary">افزودن شهر جدید</a>
</div>
<div class="card-body">
<form action="{{ route('admin.locations.cities.index') }}" method="GET" class="mb-4">
<select name="province_id" class="form-control w-25" onchange="this.form.submit()">
<option value="">همه استان‌ها</option>
@foreach($provinces as $province)
<option
value="{{ $province->id }}" {{ request('province_id') == $province->id ? 'selected' : '' }}>{{ $province->name }}</option>
@endforeach
</select>
</form>
<div class="table-responsive">
<table class="table table-bordered table-hover mb-0">
<thead>
<tr>
<th>نام شهر</th>
<th>استان</th>
<th class="text-center">عملیات</th>
</tr>
</thead>
<tbody>
@foreach($cities as $city)
<tr>
<td>{{ $city->name }}</td>
<td>{{ $city->province->name ?? '-' }}</td>
<td class="text-center">
<a href="{{ route('admin.locations.cities.edit', $city->id) }}"
class="btn btn-sm btn-info text-white">ویرایش</a>
<form action="{{ route('admin.locations.cities.destroy', $city->id) }}"
method="POST" class="d-inline">
@csrf @method('DELETE')
<button class="btn btn-sm btn-danger" onclick="return confirm('آیا مطمئنید؟')">
حذف
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-3">{{ $cities->links() }}</div>
</div>
</div>
</div>
@endsection