feat: final updates

This commit is contained in:
2026-08-22 11:11:28 -07:00
parent 618a3d4cd9
commit d4bb1b9414
43 changed files with 1136 additions and 375 deletions
@@ -1,107 +1,191 @@
@extends('admin.layouts.app')
@section('content')
<div class="container-fluid pt-4">
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="card custom-card">
<div class="card-header">
<div class="card-title">
لاگ تغییرات پرواز و تور
</div>
<div class="card-header">
<div class="card-title">
لاگ تغییرات پرواز و تور
</div>
</div>
<div class="card-body pt-0">
<div class="card-body pt-0">
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th>کاربر</th>
<th>عملیات</th>
<th>مربوط به</th>
<th>تغییرات</th>
<th>زمان</th>
</tr>
</thead>
<tbody>
@forelse($logs as $log)
<tr>
<th>کاربر</th>
<th>عملیات</th>
<th>مربوط به</th>
<th>تغییرات</th>
<th>زمان</th>
<td>
{{ optional($log->causer)->first_name ?? 'نامشخص' }}
</td>
<td>
@switch($log->event)
@case('created')
<span class="badge bg-success-transparent">ایجاد</span>
@break
@case('updated')
<span class="badge bg-warning-transparent">ویرایش</span>
@break
@case('deleted')
<span class="badge bg-danger-transparent">حذف</span>
@break
@default
{{ $log->event }}
@endswitch
</td>
<td>
{{ $log->log_name === 'flights' ? 'پرواز' : 'تور' }}
#{{ $log->subject_id }}
</td>
<td>
@if($log->event === 'updated' && $log->changes)
<ul class="mb-0 ps-3">
@foreach($log->changes['after'] as $field => $newValue)
@if(($log->changes['before'][$field] ?? null) != $newValue)
@php
$oldValue = $log->changes['before'][$field] ?? null;
@endphp
<li>
@switch($field)
@case('title')
عنوان:
«{{ $oldValue }}»
&larr;
«{{ $newValue }}»
@break
@case('status')
وضعیت:
«{{ $oldValue == 1 ? 'فعال' : 'غیرفعال' }}»
&larr;
«{{ $newValue == 1 ? 'فعال' : 'غیرفعال' }}»
@break
@case('price')
قیمت:
«{{ number_format($oldValue) }}»
&larr;
«{{ number_format($newValue) }}»
@break
@case('capacity')
ظرفیت:
«{{ $oldValue }} نفر»
&larr;
«{{ $newValue }} نفر»
@break
@case('summary')
خلاصه:
«{{ $oldValue }}»
&larr;
«{{ $newValue }}»
@break
@case('description')
توضیحات:
«{{ $oldValue }}»
&larr;
«{{ $newValue }}»
@break
@case('flight_type')
نوع پرواز:
«{{ $oldValue == 1 ? 'یک‌طرفه' : 'رفت و برگشت' }}
»
&larr;
«{{ $newValue == 1 ? 'یک‌طرفه' : 'رفت و برگشت' }}
»
@break
@case('departure_time')
زمان رفت:
«{{ $oldValue ? \Carbon\Carbon::parse($oldValue)->format('Y/m/d H:i') : '—' }}
»
به
«{{ $newValue ? \Carbon\Carbon::parse($newValue)->format('Y/m/d H:i') : '—' }}
»
@break
@case('return_time')
زمان برگشت:
«{{ $oldValue ? \Carbon\Carbon::parse($oldValue)->format('Y/m/d H:i') : '—' }}
»
به
«{{ $newValue ? \Carbon\Carbon::parse($newValue)->format('Y/m/d H:i') : '—' }}
»
@break
@default
{{ $field }}:
«{{ $oldValue ?? '—' }}»
&larr;
«{{ $newValue }}»
@endswitch
</li>
@endif
@endforeach
</ul>
@elseif($log->event === 'created')
ایجاد رکورد جدید
@else
حذف رکورد
@endif
</td>
<td>
{{ $log->created_at->toJalali()->format('Y/m/d H:i') }}
</td>
</tr>
</thead>
<tbody>
@forelse($logs as $log)
<tr>
<td>
{{ optional($log->causer)->first_name ?? 'نامشخص' }}
</td>
<td>
@switch($log->event)
@case('created')
<span class="badge bg-success-transparent">ایجاد</span>
@break
@case('updated')
<span class="badge bg-warning-transparent">ویرایش</span>
@break
@case('deleted')
<span class="badge bg-danger-transparent">حذف</span>
@break
@default
{{ $log->event }}
@endswitch
</td>
<td>
{{ $log->log_name === 'flights' ? 'پرواز' : 'تور' }}
#{{ $log->subject_id }}
</td>
<td>
@if($log->event === 'updated' && $log->changes)
<ul class="mb-0 ps-3">
@foreach($log->changes['after'] as $field => $newValue)
@if(($log->changes['before'][$field] ?? null) != $newValue)
<li>
{{ $field }}:
«{{ $log->changes['before'][$field] ?? '—' }}»
&larr;
«{{ $newValue }}»
</li>
@endif
@endforeach
</ul>
@elseif($log->event === 'created')
ایجاد رکورد جدید
@else
حذف رکورد
@endif
</td>
<td>
{{ verta($log->created_at)->format('Y/m/d H:i') }}
</td>
</tr>
@empty
<tr>
<td colspan="5" class="text-center">
لاگی ثبت نشده است
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $logs->links() }}
@empty
<tr>
<td colspan="5" class="text-center">
لاگی ثبت نشده است
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $logs->links() }}
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -124,8 +124,6 @@
</div>
</div>
{{-- مدیریت تور --}}
<div class="col-xl-6">
<label class="form-label fw-semibold">مدیریت تور</label>
@@ -168,50 +166,6 @@
</div>
{{-- مدیریت رزرو --}}
<div class="col-xl-6">
<label class="form-label fw-semibold">مدیریت رزرو</label>
<div class="d-flex gap-4 flex-wrap">
<div class="form-check">
<input class="form-check-input"
type="checkbox"
name="permissions[booking_view]"
value="1"
id="booking_view">
<label class="form-check-label" for="booking_view">
مشاهده رزرو
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="checkbox"
name="permissions[booking_edit]"
value="1"
id="booking_edit">
<label class="form-check-label" for="booking_edit">
ویرایش رزرو
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="checkbox"
name="permissions[booking_delete]"
value="1"
id="booking_delete">
<label class="form-check-label" for="booking_delete">
حذف رزرو
</label>
</div>
</div>
</div>
{{-- مدیریت کاربران --}}
<div class="col-xl-6">
<label class="form-label fw-semibold">مدیریت کاربران</label>
@@ -254,7 +208,6 @@
</div>
{{-- مدیریت مدیران --}}
<div class="col-xl-6">
<label class="form-label fw-semibold">مدیریت مدیران</label>
@@ -124,7 +124,6 @@
<div class="card-body">
<div class="row gy-4">
{{-- مدیریت پروازها --}}
<div class="col-xl-3 col-lg-6">
<h6 class="fw-semibold mb-3">مدیریت پروازها</h6>
@@ -169,7 +168,6 @@
</div>
{{-- مدیریت تورها --}}
<div class="col-xl-3 col-lg-6">
<h6 class="fw-semibold mb-3">مدیریت تورها</h6>
@@ -214,52 +212,6 @@
</div>
{{-- مدیریت رزروها --}}
<div class="col-xl-3 col-lg-6">
<h6 class="fw-semibold mb-3">مدیریت رزروها</h6>
<div class="form-check mb-2">
<input
class="form-check-input"
type="checkbox"
name="permissions[booking_view]"
value="1"
@checked($admin->permission?->booking_view)
>
<label class="form-check-label">
مشاهده رزروها
</label>
</div>
<div class="form-check mb-2">
<input
class="form-check-input"
type="checkbox"
name="permissions[booking_edit]"
value="1"
@checked($admin->permission?->booking_edit)
>
<label class="form-check-label">
ویرایش رزرو
</label>
</div>
<div class="form-check mb-2">
<input
class="form-check-input"
type="checkbox"
name="permissions[booking_delete]"
value="1"
@checked($admin->permission?->booking_delete)
>
<label class="form-check-label">
حذف رزرو
</label>
</div>
</div>
{{-- مدیریت کاربران --}}
<div class="col-xl-3 col-lg-6">
<h6 class="fw-semibold mb-3">مدیریت کاربران</h6>
@@ -304,7 +256,6 @@
</div>
{{-- مدیریت مدیران --}}
<div class="col-xl-3 col-lg-6">
<h6 class="fw-semibold mb-3">مدیریت مدیران</h6>
@@ -0,0 +1,46 @@
@extends('admin.layouts.app')
@section('content')
<div class="container-fluid pt-4">
<form action="{{ route('admin.cities.store') }}" method="POST">
@csrf
<div class="card custom-card">
<div class="card-header">
<div class="card-title">افزودن شهرستان</div>
</div>
<div class="card-body row gy-3">
<div class="col-xl-6">
<label class="form-label">نام شهرستان</label>
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="col-xl-6">
<label class="form-label">استان</label>
<select class="form-control" name="province_id">
<option value="">یک استان انتخاب کنید</option>
@foreach($provinces as $province)
<option value="{{ $province->id }}" @selected(old('province_id') == $province->id)>
{{ $province->name }}
</option>
@endforeach
</select>
@error('province_id')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ثبت</button>
</div>
</div>
</form>
</div>
@endsection
@@ -0,0 +1,47 @@
@extends('admin.layouts.app')
@section('content')
<div class="container-fluid pt-4">
<form action="{{ route('admin.cities.update', $city) }}" method="POST">
@csrf
@method('put')
<div class="card custom-card">
<div class="card-header">
<div class="card-title">ویرایش شهرستان</div>
</div>
<div class="card-body row gy-3">
<div class="col-xl-6">
<label class="form-label">نام شهرستان</label>
<input type="text" class="form-control" name="name" value="{{ old('name', $city->name) }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="col-xl-6">
<label class="form-label">استان</label>
<select class="form-control" name="province_id">
<option value="">یک استان انتخاب کنید</option>
@foreach($provinces as $province)
<option value="{{ $province->id }}" @selected(old('province_id', $city->province_id) == $province->id)>
{{ $province->name }}
</option>
@endforeach
</select>
@error('province_id')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
</div>
</div>
</form>
</div>
@endsection
+57 -2
View File
@@ -1,3 +1,58 @@
@extends('admin.layouts.app')
@section('breadcrumb')<div><h1 class="page-title fw-medium fs-18 mb-1">مدیریت شهرها</h1></div>@endsection
@section('content')<div class="container-fluid pt-4">@include('admin.partials.errors')<div class="card custom-card"><div class="card-body"><form method="GET"><div class="row g-2"><div class="col-md-5"><input class="form-control" name="search" value="{{ request('search') }}" placeholder="جستجوی شهر"></div><div class="col-md-3"><select class="form-control" name="province_id"><option value="">همه استان‌ها</option>@foreach(($provinces ?? []) as $province)<option value="{{ $province->id }}" @selected((string)request('province_id')===(string)$province->id)>{{ $province->name }}</option>@endforeach</select></div><div class="col-md-2"><button class="btn btn-light w-100">جستجو</button></div><div class="col-md-2"><a href="{{ route('admin.cities.create') }}" class="btn btn-primary w-100">شهر جدید</a></div></div></form></div></div><div class="card custom-card mt-3"><div class="table-responsive"><table class="table"><thead><tr><th>#</th><th>شهر</th><th>استان</th><th>عملیات</th></tr></thead><tbody>@forelse(($cities ?? []) as $city)<tr><td>{{ $city->id }}</td><td>{{ $city->name }}</td><td>{{ $city->province->name ?? '-' }}</td><td><a href="{{ route('admin.cities.edit',$city) }}" class="btn btn-secondary-light btn-sm">ویرایش</a><form class="d-inline" method="POST" action="{{ route('admin.cities.destroy',$city) }}" onsubmit="return confirm('حذف شهر؟')">@csrf @method('DELETE')<button class="btn btn-danger-light btn-sm">حذف</button></form></td></tr>@empty<tr><td colspan="4" class="text-center text-muted py-5">شهری ثبت نشده است.</td></tr>@endforelse</tbody></table></div></div>{{ ($cities ?? collect())->links() }}</div>@endsection
@section('content')
<div class="container-fluid pt-4">
<div class="card custom-card">
<div class="card-header d-flex align-items-center justify-content-between">
<div class="card-title">مدیریت شهرستان‌ها</div>
<a href="{{ route('admin.cities.create') }}" class="btn btn-primary btn-sm">
افزودن شهرستان
</a>
</div>
<div class="card-body pt-0">
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th>#</th>
<th>نام شهرستان</th>
<th>استان</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
@forelse($cities as $city)
<tr>
<td>{{ $city->id }}</td>
<td>{{ $city->name }}</td>
<td>{{ optional($city->province)->name ?? '—' }}</td>
<td>
<a href="{{ route('admin.cities.edit', $city) }}" class="btn btn-sm btn-warning">
ویرایش
</a>
<form action="{{ route('admin.cities.destroy', $city) }}" method="POST" class="d-inline">
@csrf
@method('delete')
<button type="submit" class="btn btn-sm btn-danger"
onclick="return confirm('آیا مطمئن هستید؟')">
حذف
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="text-center">شهرستانی ثبت نشده است</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $cities->links() }}
</div>
</div>
</div>
@endsection
+2 -2
View File
@@ -231,8 +231,8 @@
<tbody>
@forelse($recentVisits as $visit)
<tr>
<td>{{ verta($visit->created_at)->format('Y/m/d') }}</td>
<td>{{ verta($visit->created_at)->format('H:i') }}</td>
<td>{{ $visit->created_at->toJalali()->format('Y/m/d') }}</td>
<td>{{ $visit->created_at->toJalali()->format('H:i') }}</td>
<td>{{ $visit->ip_address ?? '—' }}</td>
</tr>
@empty
@@ -203,6 +203,35 @@
@enderror
</div>
<!-- Return Time -->
<div class="col-xl-6">
<label class="form-label">زمان برگشت (اختیاری)</label>
<input
type="text"
class="form-control"
name="return_time_jalali"
id="return_time_jalali"
data-jdp
data-jdp-target-value-input="#return_time_gregorian"
data-jdp-target-value-type="gregorian"
autocomplete="off"
placeholder="مثلاً 1403/06/02 18:00"
value="{{ old('return_time_jalali') }}"
>
<input
type="hidden"
name="return_time"
id="return_time_gregorian"
value="{{ old('return_time') }}"
>
@error('return_time')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Price -->
<div class="col-xl-6">
+30 -1
View File
@@ -172,7 +172,7 @@
data-jdp-target-value-type="gregorian"
autocomplete="off"
placeholder="مثلاً 1403/05/29 14:30"
value="{{ old('departure_time_jalali', $flight->departure_time ? verta($flight->departure_time)->format('Y/m/d H:i') : '') }}"
value="{{ old('departure_time_jalali', $flight->departure_time->toJalali()->format('Y/m/d H:i')) }}"
>
<input
@@ -187,6 +187,35 @@
@enderror
</div>
<!-- Return Time -->
<div class="col-xl-6">
<label class="form-label">زمان برگشت (اختیاری)</label>
<input
type="text"
class="form-control"
name="return_time_jalali"
id="return_time_jalali"
data-jdp
data-jdp-target-value-input="#return_time_gregorian"
data-jdp-target-value-type="gregorian"
autocomplete="off"
placeholder="مثلاً 1403/06/02 18:00"
value="{{ old('return_time_jalali', $flight->return_time ? $flight->return_time->toJalali()->format('Y/m/d H:i') : '') }}"
>
<input
type="hidden"
name="return_time"
id="return_time_gregorian"
value="{{ old('return_time', optional($flight->return_time)->format('Y-m-d H:i:s')) }}"
>
@error('return_time')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Price -->
<div class="col-xl-6">
<label class="form-label">قیمت</label>
@@ -138,6 +138,7 @@
<th>ایرلاین</th>
<th>نوع پرواز</th>
<th>زمان حرکت</th>
<th>زمان برگشت</th>
<th>مبدا</th>
<th>مقصد</th>
<th>قیمت</th>
@@ -214,7 +215,11 @@
</td>
<td>
{{ $flight->departure_time->toJalali()->format('H:i Y-m-d') }}
{{ $flight->departure_time->toJalali()->format('H:i Y-m-d') ?? '—' }}
</td>
<td>
{{ $flight->return_time ? $flight->return_time->toJalali()->format('H:i Y-m-d') : '—' }}
</td>
<td>
@@ -31,7 +31,7 @@
</div>
<ul class="main-menu mx-0">
<!-- Start::slide -->
<!-- داشبورد -->
<li class="slide">
<a href="{{route('admin.dashboard.index')}}"
class="side-menu__item {{activeAdminSidebar('admin.dashboard.index')}}">
@@ -40,7 +40,6 @@
</a>
</li>
<!-- مدیریت کاربران -->
@if(auth('admin')->user()->permission?->admin_view)
<li class="slide">
<a href="{{ route('admin.users.index') }}"
@@ -51,7 +50,6 @@
</li>
@endif
<!-- مدیریت تورها -->
@if(auth('admin')->user()->permission?->admin_view)
<li class="slide">
<a href="{{ route('admin.tours.index') }}"
@@ -62,7 +60,6 @@
</li>
@endif
<!-- مدیریت پروازها -->
@if(auth('admin')->user()->permission?->admin_view)
<li class="slide">
<a href="{{ route('admin.flights.index') }}"
@@ -74,7 +71,6 @@
@endif
<!-- مدیریت مدیران -->
@if(auth('admin')->user()->permission?->admin_view)
<li class="slide active">
<a href="{{route('admin.admins.index')}}"
@@ -85,7 +81,23 @@
</li>
@endif
<!-- مدیریت اطلاعات -->
<li class="slide">
<a href="{{ route('admin.provinces.index') }}"
class="side-menu__item {{activeAdminSidebar(['admin.provinces.index', 'admin.provinces.create', 'admin.provinces.edit'])}}">
<i class="ri-map-pin-line side-menu__icon"></i>
<span class="side-menu__label">مدیریت استان‌ها</span>
</a>
</li>
<li class="slide">
<a href="{{ route('admin.cities.index') }}"
class="side-menu__item {{activeAdminSidebar(['admin.cities.index', 'admin.cities.create', 'admin.cities.edit'])}}">
<i class="ri-building-line side-menu__icon"></i>
<span class="side-menu__label">مدیریت شهرستان‌ها</span>
</a>
</li>
<li class="slide">
<a href="{{ route('admin.activity-logs.index') }}"
class="side-menu__item {{activeAdminSidebar('admin.activity-logs.index')}}">
@@ -0,0 +1,28 @@
@extends('admin.layouts.app')
@section('content')
<div class="container-fluid pt-4">
<form action="{{ route('admin.provinces.store') }}" method="POST">
@csrf
<div class="card custom-card">
<div class="card-header">
<div class="card-title">افزودن استان</div>
</div>
<div class="card-body">
<label class="form-label">نام استان</label>
<input type="text" class="form-control" name="name" value="{{ old('name') }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ثبت</button>
</div>
</div>
</form>
</div>
@endsection
@@ -0,0 +1,31 @@
@extends('admin.layouts.app')
@section('content')
<div class="main-content app-content">
<div class="container-fluid pt-4">
<form action="{{ route('admin.provinces.update', $province) }}" method="POST">
@csrf
@method('put')
<div class="card custom-card">
<div class="card-header">
<div class="card-title">ویرایش استان</div>
</div>
<div class="card-body">
<label class="form-label">نام استان</label>
<input type="text" class="form-control" name="name" value="{{ old('name', $province->name) }}">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
</div>
</div>
</form>
</div>
</div>
@endsection
@@ -1,3 +1,58 @@
@extends('admin.layouts.app')
@section('breadcrumb')<div><h1 class="page-title fw-medium fs-18 mb-1">مدیریت استان‌ها</h1></div>@endsection
@section('content')<div class="container-fluid pt-4">@include('admin.partials.errors')<div class="card custom-card"><div class="card-body"><form method="GET"><div class="row g-2"><div class="col-md-8"><input class="form-control" name="search" value="{{ request('search') }}" placeholder="جستجوی استان"></div><div class="col-md-2"><button class="btn btn-light w-100">جستجو</button></div><div class="col-md-2"><a href="{{ route('admin.provinces.create') }}" class="btn btn-primary w-100">استان جدید</a></div></div></form></div></div><div class="card custom-card mt-3"><div class="table-responsive"><table class="table"><thead><tr><th>#</th><th>استان</th><th>عملیات</th></tr></thead><tbody>@forelse(($provinces ?? []) as $province)<tr><td>{{ $province->id }}</td><td>{{ $province->name }}</td><td><a href="{{ route('admin.provinces.edit',$province) }}" class="btn btn-secondary-light btn-sm">ویرایش</a><form class="d-inline" method="POST" action="{{ route('admin.provinces.destroy',$province) }}" onsubmit="return confirm('حذف استان؟')">@csrf @method('DELETE')<button class="btn btn-danger-light btn-sm">حذف</button></form></td></tr>@empty<tr><td colspan="3" class="text-center text-muted py-5">استانی ثبت نشده است.</td></tr>@endforelse</tbody></table></div></div>{{ ($provinces ?? collect())->links() }}</div>@endsection
@section('content')
<div class="container-fluid pt-4">
<div class="card custom-card">
<div class="card-header d-flex align-items-center justify-content-between">
<div class="card-title">مدیریت استان‌ها</div>
<a href="{{ route('admin.provinces.create') }}" class="btn btn-primary btn-sm">
افزودن استان
</a>
</div>
<div class="card-body pt-0">
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th>#</th>
<th>نام استان</th>
<th>تعداد شهرستان</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
@forelse($provinces as $province)
<tr>
<td>{{ $province->id }}</td>
<td>{{ $province->name }}</td>
<td>{{ $province->cities_count }}</td>
<td>
<a href="{{ route('admin.provinces.edit', $province) }}" class="btn btn-sm btn-warning">
ویرایش
</a>
<form action="{{ route('admin.provinces.destroy', $province) }}" method="POST" class="d-inline">
@csrf
@method('delete')
<button type="submit" class="btn btn-sm btn-danger"
onclick="return confirm('آیا مطمئن هستید؟')">
حذف
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="text-center">استانی ثبت نشده است</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $provinces->links() }}
</div>
</div>
</div>
@endsection
+62 -1
View File
@@ -63,6 +63,41 @@
<span style="color: red">{{ $message }}</span>
@enderror
</div>
<div class="col-xl-6">
<label class="form-label">استان</label>
<select name="province_id" id="province_id" class="form-control">
<option value="">استان را انتخاب کنید</option>
@foreach($provinces as $province)
<option
value="{{ $province->id }}"
@selected(old('province_id', $user->province_id) == $province->id)
>
{{ $province->name }}
</option>
@endforeach
</select>
@error('province_id')
<span style="color: red">{{ $message }}</span>
@enderror
</div>
<div class="col-xl-6">
<label class="form-label">شهرستان</label>
<select name="city_id" id="city_id" class="form-control">
@if($user->city)
<option value="{{ $user->city->id }}" selected>
{{ $user->city->name }}
</option>
@else
<option value="">ابتدا استان را انتخاب کنید</option>
@endif
</select>
@error('city_id')
<span style="color: red">{{ $message }}</span>
@enderror
</div>
<div class="col-xl-6">
<label class="form-label">رمز عبور (در صورت تغییر)</label>
<input type="text" class="form-control" name="password"
@@ -84,5 +119,31 @@
</div>
</div>
@endsection
<script>
document.getElementById('province_id').addEventListener('change', function () {
const provinceId = this.value;
const citySelect = document.getElementById('city_id');
citySelect.innerHTML = '<option value="">در حال بارگذاری...</option>';
if (!provinceId) {
citySelect.innerHTML = '<option value="">ابتدا استان را انتخاب کنید</option>';
return;
}
fetch(`/admin/users/cities-by-province/${provinceId}`)
.then(response => response.json())
.then(cities => {
citySelect.innerHTML = '<option value="">شهرستان خود را انتخاب کنید</option>';
cities.forEach(city => {
const option = document.createElement('option');
option.value = city.id;
option.textContent = city.name;
citySelect.appendChild(option);
});
});
});
</script>
@endsection
+2 -2
View File
@@ -191,10 +191,10 @@
{{ $user->email }}
</td>
<td>
{{$user->province}}
{{ $user->province?->name ?? '-' }}
</td>
<td>
{{$user->city}}
{{ $user->city?->name ?? '-' }}
</td>
<td>
{{ $user->mobile }}