feat(admin): complete admin management and add edit functionality

This commit is contained in:
2026-08-20 11:56:46 +03:30
parent 0a0ee7ca5a
commit 3867350331
16 changed files with 1883 additions and 39 deletions
+150 -9
View File
@@ -2,8 +2,11 @@
namespace App\Http\Controllers\Admin;
use App\Enums\Admin\AdminRole;
use App\Enums\Admin\AdminStatus;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\AdminStoreRequest;
use App\Http\Requests\Admin\AdminUpdateRequest;
use App\Models\Admin;
use App\Models\AdminAvatar;
use App\Models\AdminPermission;
@@ -80,7 +83,152 @@ class AdminController extends Controller
public function edit(Admin $admin)
{
return view('admin.admins.edit', compact('admin'));
$title = 'جزئیات مدیر';
$loggedInAdmin = auth('admin')->user();
$canEditSensitiveFields = $loggedInAdmin->isSuperAdmin() && $loggedInAdmin->id !== $admin->id;
$showReadonlySensitiveFields = $loggedInAdmin->id === $admin->id;
$adminRoles = AdminRole::cases();
$adminStatuses = AdminStatus::cases();
$admin->load([
'avatar.file',
'permissions',
]);
return view('admin.admins.edit', compact(
'title',
'admin',
'adminRoles',
'adminStatuses',
'canEditSensitiveFields',
'showReadonlySensitiveFields'
));
}
public function update(AdminUpdateRequest $request,Admin $admin)
{
$data = $request->validated();
$newAvatarPath = null;
$oldFile = null;
DB::beginTransaction();
try {
$updateData = [
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'username' => $data['username'],
'email' => $data['email'] ?? null,
'mobile' => $data['mobile'] ?? null,
];
if (!empty($data['password'])) {
$updateData['password'] = Hash::make($data['password']);
}
$loggedInAdmin = auth('admin')->user();
$canEditSensitiveFields =
$loggedInAdmin->isSuperAdmin()
&& $loggedInAdmin->id !== $admin->id;
if ($canEditSensitiveFields) {
if (array_key_exists('role', $data)) {
$updateData['role'] = $data['role'];
}
if (array_key_exists('status', $data)) {
$updateData['status'] = $data['status'];
}
}
$admin->update($updateData);
if ($canEditSensitiveFields && array_key_exists('permissions', $data)) {
$admin->permissions()->delete();
if (!$admin->isSuperAdmin()) {
foreach ($data['permissions'] ?? [] as $permission) {
$admin->permissions()->create([
'permission' => $permission,
]);
}
}
}
if ($request->hasFile('image')) {
$oldAvatar = $admin->avatar()
->with('file')
->first();
$oldFile = $oldAvatar?->file;
$image = $data['image'];
$imageName = $admin->id
. '_' . time() . rand(11111, 99999) . '.' . $image->extension();
$newAvatarPath = $image->storeAs(
'admin_avatars',
$imageName,
'public'
);
$file = File::create([
'name' => $imageName,
'size' => $image->getSize(),
'original_name' => $image->getClientOriginalName(),
'path' => $newAvatarPath,
'extension' => $image->extension(),
]);
if ($oldAvatar) {
$oldAvatar->update([
'file_id' => $file->id,
]);
} else {
AdminAvatar::create([
'admin_id' => $admin->id,
'file_id' => $file->id,
]);
}
}
DB::commit();
if ($oldFile) {
deleteFile($oldFile);
}
$redirectRoute = $loggedInAdmin->isSuperAdmin()
? 'admin.admins.index'
: 'admin.profile.index';
return redirect()
->route($redirectRoute)
->with('success', 'اطلاعات مدیر با موفقیت ویرایش شد.');
} catch (\Exception $exception) {
DB::rollBack();
if ($newAvatarPath && Storage::disk('public')->exists($newAvatarPath)) {
Storage::disk('public')->delete($newAvatarPath);
}
Log::error($exception);
return back()
->withInput()
->with('error', 'ویرایش مدیر با خطا مواجه شد.');
}
}
public function create()
@@ -113,13 +261,7 @@ class AdminController extends Controller
if ($request->hasFile('image')) {
$image = $request->file('image');
$imageName = $admin->id
. '_'
. time()
. '_'
. rand(11111, 99999)
. '.'
. $image->extension();
$imageName = $admin->id . '_' . time() . '_' . rand(11111, 99999) . '.' . $image->extension();
$avatarPath = $image->storeAs(
'admin_avatars',
@@ -172,7 +314,6 @@ class AdminController extends Controller
->withInput(
$request->except([
'password',
'password_confirmation',
'image',
])
)
@@ -17,7 +17,7 @@ class CheckAdminPermission
{
$admin = auth('admin')->user();
if (! auth('admin')->user()?->hasPermission($permission)) {
if (! auth('admin')->user()?->canAccess($permission)) {
abort(403);
}
@@ -0,0 +1,103 @@
<?php
namespace App\Http\Requests\Admin;
use App\Enums\Admin\AdminRole;
use App\Enums\Admin\AdminStatus;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class AdminUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$admin = $this->route('admin');
return [
'first_name' => [
'required',
'string',
'max:64',
'persianAlpha',
],
'last_name' => [
'required',
'string',
'max:64',
'persianAlpha',
],
'username' => [
'required',
'string',
'min:3',
'max:100',
'regex:/^[a-zA-Z][a-zA-Z0-9_]*$/',
Rule::unique('admins', 'username')->ignore($admin),
],
'email' => [
'nullable',
'string',
'email',
'max:150',
Rule::unique('admins', 'email')->ignore($admin),
],
'mobile' => [
'nullable',
'string',
'regex:/^09\d{9}$/',
'ir_mobile:zero',
Rule::unique('admins', 'mobile')->ignore($admin),
],
'password' => [
'nullable',
'string',
'min:8',
'max:255',
],
'role' => [
'nullable',
Rule::enum(AdminRole::class),
],
'status' => [
'nullable',
Rule::enum(AdminStatus::class),
],
'permissions' => [
'nullable',
'array',
],
'permissions.*' => [
'required',
'string',
],
'image' => [
'nullable',
'image',
'mimes:jpg,jpeg,png,webp',
'max:800',
],
];
}
}
+2 -2
View File
@@ -84,7 +84,7 @@ if (!function_exists('getUserFullName')) {
}
}
if (! function_exists('deleteFile')) {
function deleteFile(?File $file): void
function deleteFile(?\App\Models\File $file): void
{
if (! $file) {
return;
@@ -107,7 +107,7 @@ if (!function_exists('getFileUrl')) {
return null;
}
$file = File::find($fileId);
$file = \App\Models\File::find($fileId);
if (!$file){
return null;
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+2 -6
View File
@@ -83,7 +83,6 @@
<table class="table text-nowrap table-bordered">
<thead>
<tr>
<th><input class="form-check-input check-all" type="checkbox" id="all-admins"></th>
<th>تصویر</th>
<th>نام</th>
<th>نام خانوادگی</th>
@@ -99,13 +98,10 @@
<tbody>
@forelse($admins as $admin)
<tr>
<td>
<input class="form-check-input" type="checkbox" value="{{ $admin->id }}">
</td>
<td>
<span class="avatar avatar-md avatar-square bg-light">
@if($admin->file)
<img src="{{ getFileUrl($admin->file_id) }}" class="w-100 h-100" alt="{{ $admin->username }}">
@if($admin->avatar && $admin->avatar->file)
<img src="{{ getFileUrl($admin->avatar->file_id) }}" class="w-100 h-100" alt="{{ $admin->username }}"
@else
<img src="{{asset('assets/admin/images/faces/DefaultAvatar.jpg')}}"
class="w-100 h-100" alt="{{$admin->username}}">
+10 -2
View File
@@ -93,10 +93,17 @@
data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
<div class="d-flex align-items-center">
<div>
@if(auth('admin')->user()->avatar?->file)
<img
src="{{asset('Admin/assets/admin/images/faces/DefaultAvatar.jpg')}}"
src="{{ getFileUrl(auth('admin')->user()->avatar->file_id) }}"
alt="img"
class="avatar avatar-sm avatar-rounded">
@else
<img
src="{{ asset('assets/admin/images/faces/DefaultAvatar.jpg') }}"
alt="img"
class="avatar avatar-sm avatar-rounded">
@endif
</div>
</div>
</a>
@@ -106,7 +113,8 @@
<li class="p-3 border-bottom">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 fw-semibold lh-1">{{auth('admin')->user()->first_name }} | {{ auth('admin')->user()->last_name }}</p>
<p class="mb-0 fw-semibold lh-1">{{auth('admin')->user()->first_name }}
| {{ auth('admin')->user()->last_name }}</p>
<span class="fs-11 text-muted">{{auth('admin')->user()->username}}</span>
</div>
</div>
+230
View File
@@ -0,0 +1,230 @@
@extends('admin.layouts.app')
@section('breadcrumb')
<div>
<div>
<h1 class="page-title fw-medium fs-18 mb-2">سطل زباله تورها</h1>
<div>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="javascript:void(0);">تور‌ها</a>
</li>
<li class="breadcrumb-item">
<a href="{{ route('admin.tours.index') }}">
لیست تورها
</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
سطل زباله تورها
</li>
</ol>
</nav>
</div>
</div>
</div>
@endsection
@section('content')
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="card-body p-3">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-3">
<div>
<h6 class="mb-0 fw-semibold">
تورهای حذف‌شده
</h6>
</div>
<div class="d-flex">
<a href="{{ route('admin.tours.index') }}"
class="btn btn-primary me-2">
<i class="ri-arrow-go-back-line me-1 fw-medium align-middle"></i>
بازگشت به لیست تورها
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="table-responsive">
<table class="table text-nowrap table-bordered">
<thead>
<tr>
<th>تصویر</th>
<th>عنوان تور</th>
<th>مبدأ</th>
<th>مقصد</th>
<th>نوع تور</th>
<th>محدوده تور</th>
<th>تاریخ ایجاد</th>
<th>تاریخ حذف</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
@if(session('success'))
<tr>
<td colspan="9">
<span style="color: green">
{{ session('success') }}
</span>
</td>
</tr>
@endif
@if(session('error'))
<tr>
<td colspan="9">
<span style="color: red">
{{ session('error') }}
</span>
</td>
</tr>
@endif
@if($errors->any())
<tr>
<td colspan="9">
@foreach($errors->all() as $error)
<span class="d-block" style="color: red">
{{ $error }}
</span>
@endforeach
</td>
</tr>
@endif
@forelse($tours as $tour)
<tr>
<td>
<span class="avatar avatar-md avatar-square bg-light">
@if($tour->coverImage?->file)
<img src="{{ getFileUrl($tour->coverImage->file_id) }}"
class="w-100 h-100"
alt="{{ $tour->title }}">
@else
<img src="{{ asset('assets/admin/images/faces/DefaultAvatar.jpg') }}"
class="w-100 h-100"
alt="{{ $tour->title }}">
@endif
</span>
</td>
<td>
<div class="fw-medium">
{{ $tour->title }}
</div>
@if($tour->summary)
<small class="text-muted d-inline-block text-truncate"
style="max-width: 180px;">
{{ $tour->summary }}
</small>
@endif
</td>
<td>
{{ $tour->originCity?->name ?? '-' }}
</td>
<td>
{{ $tour->city?->name ?? '-' }}
</td>
<td>
@if($tour->tour_type)
<span class="badge bg-success-transparent">
{{ $tour->tour_type->label() }}
</span>
@else
-
@endif
</td>
<td>
@if($tour->tour_scope)
<span class="badge bg-primary-transparent">
{{ $tour->tour_scope->label() }}
</span>
@else
-
@endif
</td>
<td>
{{ $tour->created_at?->toJalali()->format('H:i Y/m/d') ?? '-' }}
</td>
<td>
{{ $tour->deleted_at?->toJalali()->format('H:i Y/m/d') ?? '-' }}
</td>
<td>
<div class="hstack gap-2 fs-15">
<form action="{{ route('admin.tours.trash.restore', $tour->id) }}"
method="POST">
@csrf
<button type="submit"
class="btn btn-icon btn-sm btn-success-light"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="بازگردانی تور">
<i class="ri-arrow-go-back-line"></i>
</button>
</form>
<form action="{{ route('admin.tours.trash.forceDelete', $tour->id) }}"
method="POST"
onsubmit="return confirm('آیا از حذف دائمی این تور مطمئن هستید؟ این عملیات قابل بازگشت نیست.')">
@csrf
@method('DELETE')
<button type="submit"
class="btn btn-icon btn-sm btn-danger-light"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="حذف دائمی تور">
<i class="ri-delete-bin-6-line"></i>
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="9" class="text-center text-muted py-4">
توری در سطل زباله وجود ندارد.
</td>
</tr>
@endforelse
</tbody>
</table>
<div class="card-footer d-flex justify-content-center align-items-center">
{{ $tours->links() }}
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
+4 -2
View File
@@ -108,8 +108,10 @@ Route::prefix('admin')->name('admin.')->group(function () {
Route::get('create', 'create')->name('create');
Route::post('store', 'store')->name('store');
Route::prefix('trash')->group(function () {
Route::get('/', 'trash')->name('trash');
Route::get('cities-by-country/{country}', 'citiesByCountry')->name('citiesByCountry');
Route::prefix('trash')->name('trash.')->group(function () {
Route::get('/', 'trash')->name('index');
Route::prefix('{id}')->group(function () {
Route::post('restore', 'restore')->name('restore');
@@ -0,0 +1,269 @@
<?php $__env->startSection('breadcrumb'); ?>
<div>
<h1 class="page-title fw-medium fs-18 mb-2">لیست تورها</h1>
<div>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="javascript:void(0);">تور‌ها</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
لیست تورها
</li>
</ol>
</nav>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-4">
<?php if(session('success')): ?>
<span style="color: green"><?php echo e(session('success')); ?></span>
<?php endif; ?>
<?php if(session('error')): ?>
<span style="color: red"><?php echo e(session('error')); ?></span>
<?php endif; ?>
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="card-body p-3">
<form method="GET" action="<?php echo e(route('admin.tours.index')); ?>">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-3">
<div class="d-flex flex-wrap gap-1 project-list-main align-items-center">
<div class="d-flex me-2">
<input class="form-control me-2"
type="search"
name="search"
placeholder="جست‌وجوی عنوان یا شهر"
value="<?php echo e(request()->input('search')); ?>"
aria-label="جست‌وجو">
<button class="btn btn-light" type="submit">
جست‌وجو
</button>
</div>
<select id="choices-single-default"
class="form-control"
name="sort"
onchange="this.form.submit()">
<option value="">مرتب‌سازی بر اساس</option>
<option value="newest"
<?php if(request()->missing('sort') || request()->input('sort') === 'newest'): echo 'selected'; endif; ?>>
جدیدترین
</option>
<option value="lowest"
<?php if(request()->input('sort') === 'lowest'): echo 'selected'; endif; ?>>
کمترین قیمت
</option>
<option value="highest"
<?php if(request()->input('sort') === 'highest'): echo 'selected'; endif; ?>>
بیشترین قیمت
</option>
</select>
</div>
<div class="d-flex align-items-center gap-2">
<a href="<?php echo e(route('admin.tours.trash.index')); ?>"
class="btn btn-danger-light d-flex align-items-center">
<i class="ri-delete-bin-3-line me-1 fw-medium align-middle"></i>
سطل زباله
</a>
<a href="<?php echo e(route('admin.tours.create')); ?>"
class="btn btn-primary me-2">
<i class="ri-add-line me-1 fw-medium align-middle"></i>
ایجاد تور
</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="table-responsive">
<table class="table text-nowrap table-bordered">
<thead>
<tr>
<th>تصویر</th>
<th>عنوان تور</th>
<th>مبدأ</th>
<th>مقصد</th>
<th>نوع تور</th>
<th>محدوده تور</th>
<th>شیوه برگزاری</th>
<th>تعداد حرکت‌ها</th>
<th>بازه قیمت</th>
<th>بازدید صفحه</th>
<th>تاریخ ایجاد</th>
<th>اقدامات</th>
</tr>
</thead>
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $tours; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tour): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr>
<td>
<span class="avatar avatar-md avatar-square bg-light">
<?php if($tour->coverImage?->file): ?>
<img src="<?php echo e(getFileUrl($tour->coverImage->file_id)); ?>"
class="w-100 h-100"
alt="<?php echo e($tour->title); ?>">
<?php else: ?>
<img src="<?php echo e(asset('assets/Admin/images/tour/single-2.jpg')); ?>"
class="w-100 h-100"
alt="<?php echo e($tour->title); ?>">
<?php endif; ?>
</span>
</td>
<td>
<div class="fw-medium">
<?php echo e($tour->title); ?>
</div>
<?php if($tour->summary): ?>
<small class="text-muted d-inline-block text-truncate"
style="max-width: 180px;">
<?php echo e($tour->summary); ?>
</small>
<?php endif; ?>
</td>
<td>
<?php echo e($tour->originCity?->name ?? '-'); ?>
</td>
<td>
<?php echo e($tour->city?->name ?? '-'); ?>
</td>
<td>
<?php if($tour->tour_scope): ?>
<span class="badge bg-primary-transparent">
<?php echo e($tour->tour_scope->label()); ?>
</span>
<?php else: ?>
-
<?php endif; ?>
</td>
<td>
<?php if($tour->tour_mode): ?>
<span class="badge bg-warning-transparent">
<?php echo e($tour->tour_mode->label()); ?>
</span>
<?php else: ?>
-
<?php endif; ?>
</td>
<td>
<?php if($tour->tour_type): ?>
<span class="badge bg-success-transparent">
<?php echo e($tour->tour_type->label()); ?>
</span>
<?php else: ?>
-
<?php endif; ?>
</td>
<td>
<span class="badge bg-info-transparent">
<?php echo e($tour->tour_departures_count); ?> حرکت
</span>
</td>
<td>
<?php if($tour->tour_departures_min_price === $tour->tour_departures_max_price): ?>
<?php echo e(number_format($tour->tour_departures_min_price)); ?> تومان
<?php else: ?>
<?php echo e(number_format($tour->tour_departures_min_price)); ?>
-
<?php echo e(number_format($tour->tour_departures_max_price)); ?>
تومان
<?php endif; ?>
</td>
<td>
<?php echo e($tour->views_count ?? 0); ?>
</td>
<td>
<?php echo e($tour->created_at->toJalali()->format('d F Y - H:i')); ?>
</td>
<td>
<div class="hstack gap-2 fs-15">
<a href="<?php echo e(route('admin.tours.edit', $tour->id)); ?>"
class="btn btn-secondary-light btn-icon btn-sm"
title="ویرایش">
<i class="ti ti-pencil"></i>
</a>
<form action="<?php echo e(route('admin.tours.destroy', $tour->id)); ?>"
method="POST"
class="d-inline"
onsubmit="return confirm('از حذف این تور مطمئن هستید؟')">
<?php echo csrf_field(); ?>
<?php echo method_field('DELETE'); ?>
<button type="submit"
class="btn btn-icon btn-sm btn-danger-light"
title="حذف">
<i class="ri-delete-bin-line"></i>
</button>
</form>
</div>
</td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<tr>
<td colspan="11" class="text-center text-muted py-4">
هیچ توری یافت نشد.
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-end mt-3">
<?php echo e($tours->links()); ?>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\Desktop\airline-agency\resources\views/admin/tours/index.blade.php ENDPATH**/ ?>
@@ -55,7 +55,7 @@
<!-- Right: Trash Button -->
<div class="d-flex align-items-center gap-2">
<a href="<?php echo e(route('admin.users.trash')); ?>" class="btn btn-danger-light d-flex align-items-center">
<a href="<?php echo e(route('admin.users.trash.index')); ?>" class="btn btn-danger-light d-flex align-items-center">
<i class="ri-delete-bin-3-line me-1 fw-medium align-middle"></i>
سطل زباله
</a>
@@ -93,10 +93,17 @@
data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
<div class="d-flex align-items-center">
<div>
<?php if(auth('admin')->user()->avatar?->file): ?>
<img
src="<?php echo e(asset('Admin/assets/admin/images/faces/DefaultAvatar.jpg')); ?>"
src="<?php echo e(getFileUrl(auth('admin')->user()->avatar->file_id)); ?>"
alt="img"
class="avatar avatar-sm avatar-rounded">
<?php else: ?>
<img
src="<?php echo e(asset('assets/admin/images/faces/DefaultAvatar.jpg')); ?>"
alt="img"
class="avatar avatar-sm avatar-rounded">
<?php endif; ?>
</div>
</div>
</a>
@@ -106,7 +113,9 @@
<li class="p-3 border-bottom">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 fw-semibold lh-1"><?php echo e(auth('admin')->user()->first_name); ?> | <?php echo e(auth('admin')->user()->last_name); ?></p>
<p class="mb-0 fw-semibold lh-1"><?php echo e(auth('admin')->user()->first_name); ?>
| <?php echo e(auth('admin')->user()->last_name); ?></p>
<span class="fs-11 text-muted"><?php echo e(auth('admin')->user()->username); ?></span>
</div>
</div>
@@ -0,0 +1,434 @@
<?php $__env->startSection('breadcrumb'); ?>
<div>
<div>
<h1 class="page-title fw-medium fs-18 mb-2">ویرایش تور</h1>
<div>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="<?php echo e(route('admin.tours.index')); ?>">مدیریت تورها</a></li>
<li class="breadcrumb-item active" aria-current="page">ویرایش تور</li>
</ol>
</nav>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-4">
<?php if(session('success')): ?>
<span style="color: green"><?php echo e(session('success')); ?></span>
<?php endif; ?>
<?php if(session('error')): ?>
<span style="color: red"><?php echo e(session('error')); ?></span>
<?php endif; ?>
<div class="row">
<div class="col-xl-12">
<form action="<?php echo e(route('admin.tours.update', $tour->id)); ?>" method="POST" enctype="multipart/form-data">
<?php echo csrf_field(); ?>
<?php echo method_field('PUT'); ?>
<div class="card custom-card">
<div class="card-header">
<div class="card-title">مشخصات اصلی تور</div>
</div>
<div class="card-body pt-0">
<div class="row gy-3">
<div class="col-xl-6">
<label class="form-label">عنوان تور <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="title"
value="<?php echo e(old('title', $tour->title)); ?>">
<?php $__errorArgs = ['title'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">گستره تور <span class="text-danger">*</span></label>
<select class="form-control" name="tour_scope" id="tourScopeSelect">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourScope::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scope): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($scope->value); ?>"
<?php echo e(old('tour_scope', $tour->tour_scope?->value) == $scope->value ? 'selected' : ''); ?>>
<?php echo e($scope->label()); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_scope'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">نوع حمل و نقل / سفر <span
class="text-danger">*</span></label>
<select class="form-control" name="tour_mode">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourMode::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mode): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($mode->value); ?>"
<?php echo e(old('tour_mode', $tour->tour_mode?->value) == $mode->value ? 'selected' : ''); ?>>
<?php echo e($mode->label()); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_mode'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">سبک تور <span class="text-danger">*</span></label>
<select class="form-control" name="tour_type">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourType::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($type->value); ?>"
<?php echo e(old('tour_type', $tour->tour_type?->value) == $type->value ? 'selected' : ''); ?>>
<?php echo e($type->label()); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_type'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">شهر مبدا <span class="text-danger">*</span></label>
<select class="form-control select2" name="origin_city_id">
<option value="">شهر مبدا را انتخاب کنید</option>
<?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($city->id); ?>"
<?php echo e(old('origin_city_id', $tour->origin_city_id) == $city->id ? 'selected' : ''); ?>>
<?php echo e($city->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['origin_city_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6" id="countryWrapper"
style="<?php echo e($tour->tour_scope === \App\Enums\Admin\Tour\TourScope::INTERNATIONAL ? '' : 'display:none;'); ?>">
<label class="form-label">کشور مقصد</label>
<select class="form-control" id="country_id"
<?php echo e($tour->tour_scope === \App\Enums\Admin\Tour\TourScope::INTERNATIONAL ? '' : 'disabled'); ?>>
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($country->id); ?>"
<?php echo e($selectedCountryId == $country->id ? 'selected' : ''); ?>>
<?php echo e($country->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
</div>
<div class="col-xl-6">
<label class="form-label">شهر مقصد <span class="text-danger">*</span></label>
<select class="form-control select2" name="destination_city_id">
<option value="">شهر مقصد را انتخاب کنید</option>
<?php $__currentLoopData = $destinationCities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($city->id); ?>"
<?php echo e(old('destination_city_id', $tour->destination_city_id) == $city->id ? 'selected' : ''); ?>>
<?php echo e($city->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['destination_city_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-12">
<label class="form-label">خلاصه تور</label>
<textarea class="form-control" name="summary"
rows="2"><?php echo e(old('summary', $tour->summary)); ?></textarea>
<?php $__errorArgs = ['summary'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-12">
<label class="form-label">توضیحات کامل و برنامه سفر</label>
<textarea class="form-control" name="description"
rows="5"><?php echo e(old('description', $tour->description)); ?></textarea>
<?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
</div>
<hr class="my-4">
<h6 class="fw-bold mb-3">اطلاعات ظرفیت / زمان‌بندی حرکت</h6>
<div class="row gy-3">
<div class="col-xl-3">
<label class="form-label">تاریخ رفت (شروع)</label>
<input
type="text"
id="startDateInput"
class="form-control"
name="start_date"
value="<?php echo e(old(
'start_date',$departure?->start_date ? Verta::instance($departure->start_date)->format('Y/m/d H:i') : '' )); ?>">
<?php $__errorArgs = ['start_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">تاریخ برگشت (پایان)</label>
<input
type="text"
id="endDateInput"
class="form-control"
name="end_date"
value="<?php echo e(old('end_date',$departure?->end_date ? Verta::instance($departure->end_date)->format('Y/m/d H:i') : '')); ?>">
<?php $__errorArgs = ['end_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">قیمت (تومان)</label>
<input type="text" class="form-control" name="price"
value="<?php echo e(old('price', $departure?->price)); ?>">
<?php $__errorArgs = ['price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">ظرفیت مسافر</label>
<input type="number" class="form-control" name="capacity"
value="<?php echo e(old('capacity', $departure?->capacity)); ?>">
<?php $__errorArgs = ['capacity'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
</div>
<hr class="my-4">
<h6 class="fw-bold mb-2">گالری تصاویر فعلی</h6>
<div class="d-flex flex-wrap gap-2 mb-3">
<?php $__empty_1 = true; $__currentLoopData = $tour->images; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $image): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<div class="position-relative" style="width:120px;height:120px;">
<img src="<?php echo e(getFileUrl($image->file_id)); ?>"
class="w-100 h-100 rounded"
style="object-fit:cover;"
alt="<?php echo e($tour->title); ?>">
<?php if($image->is_default): ?>
<span
class="badge bg-primary position-absolute top-0 start-0 m-1">اصلی</span>
<?php endif; ?>
</div>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<span class="text-muted">هیچ تصویری ثبت نشده است.</span>
<?php endif; ?>
</div>
<h6 class="fw-bold mb-2">افزودن تصاویر جدید</h6>
<div class="image-upload-wrapper d-flex flex-wrap gap-2 px-0 pt-0 mt-2"
id="imagePreviewContainer" style="border-radius: 8px; padding: 10px;">
<label id="uploadPlaceholder" class="upload-placeholder" for="imageInput"
style="cursor: pointer; width:150px; height:150px; display: flex; justify-content: center; align-items: center; border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center;">
<div>📷<br><strong>آپلود تصاویر</strong></div>
<small style="color:#999;">JPG / PNG / WEBP</small>
</label>
<input id="imageInput" name="images[]" type="file"
accept=".jpg,.png,.jpeg,.webp" multiple style="display:none">
</div>
<?php $__errorArgs = ['images'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small d-block"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ذخیره تغییرات</button>
</div>
</div>
</form>
</div>
</div>
</div>
<?php $__env->startPush('scripts'); ?>
<script>
$(document).ready(function () {
$('#startDateInput').persianDatepicker({
format: 'YYYY/MM/DD HH:mm',
timePicker: {
enabled: true,
meridiem: {
enabled: false
}
},
autoClose: false,
initialValue: false,
initialValueType: 'persian',
toolbox: {
calendarSwitch: {
enabled: false
}
}
});
$('#endDateInput').persianDatepicker({
format: 'YYYY/MM/DD HH:mm',
timePicker: {
enabled: true,
meridiem: {
enabled: false
}
},
autoClose: false,
initialValue: false,
initialValueType: 'persian',
toolbox: {
calendarSwitch: {
enabled: false
}
}
});
function toggleScopeUI() {
const scope = $('#tourScopeSelect').val();
if (scope === '1') {
$('#countryWrapper').show();
$('#country_id').prop('disabled', false);
} else {
$('#countryWrapper').hide();
$('#country_id').prop('disabled', true).val('');
}
}
$('#tourScopeSelect').on('change', toggleScopeUI);
$('#country_id').on('change', function () {
const countryId = $(this).val();
if (!countryId) return;
$.get(`/admin/tours/cities-by-country/${countryId}`, function (cities) {
let options = '<option value="">شهر را انتخاب کنید</option>';
cities.forEach(function (city) {
options += `<option value="${city.id}">${city.name}</option>`;
});
$('select[name="destination_city_id"]').html(options).trigger('change');
}).fail(function () {
alert('خطا در دریافت لیست شهرهای این کشور');
});
});
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\Desktop\airline-agency\resources\views/admin/tours/edit.blade.php ENDPATH**/ ?>
@@ -80,7 +80,6 @@
<table class="table text-nowrap table-bordered">
<thead>
<tr>
<th><input class="form-check-input check-all" type="checkbox" id="all-admins"></th>
<th>تصویر</th>
<th>نام</th>
<th>نام خانوادگی</th>
@@ -96,13 +95,10 @@
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $admins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $admin): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr>
<td>
<input class="form-check-input" type="checkbox" value="<?php echo e($admin->id); ?>">
</td>
<td>
<span class="avatar avatar-md avatar-square bg-light">
<?php if($admin->file): ?>
<img src="<?php echo e(getFileUrl($admin->file_id)); ?>" class="w-100 h-100" alt="<?php echo e($admin->username); ?>">
<?php if($admin->avatar && $admin->avatar->file): ?>
<img src="<?php echo e(getFileUrl($admin->avatar->file_id)); ?>" class="w-100 h-100" alt="<?php echo e($admin->username); ?>"
<?php else: ?>
<img src="<?php echo e(asset('assets/admin/images/faces/DefaultAvatar.jpg')); ?>"
class="w-100 h-100" alt="<?php echo e($admin->username); ?>">
@@ -0,0 +1,242 @@
<?php $__env->startSection('breadcrumb'); ?>
<div>
<div>
<h1 class="page-title fw-medium fs-18 mb-2">سطل زباله تورها</h1>
<div>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item">
<a href="javascript:void(0);">تور‌ها</a>
</li>
<li class="breadcrumb-item">
<a href="<?php echo e(route('admin.tours.index')); ?>">
لیست تورها
</a>
</li>
<li class="breadcrumb-item active" aria-current="page">
سطل زباله تورها
</li>
</ol>
</nav>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="card-body p-3">
<div class="d-flex align-items-center justify-content-between flex-wrap gap-3">
<div>
<h6 class="mb-0 fw-semibold">
تورهای حذف‌شده
</h6>
</div>
<div class="d-flex">
<a href="<?php echo e(route('admin.tours.index')); ?>"
class="btn btn-primary me-2">
<i class="ri-arrow-go-back-line me-1 fw-medium align-middle"></i>
بازگشت به لیست تورها
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="table-responsive">
<table class="table text-nowrap table-bordered">
<thead>
<tr>
<th>تصویر</th>
<th>عنوان تور</th>
<th>مبدأ</th>
<th>مقصد</th>
<th>نوع تور</th>
<th>محدوده تور</th>
<th>تاریخ ایجاد</th>
<th>تاریخ حذف</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
<?php if(session('success')): ?>
<tr>
<td colspan="9">
<span style="color: green">
<?php echo e(session('success')); ?>
</span>
</td>
</tr>
<?php endif; ?>
<?php if(session('error')): ?>
<tr>
<td colspan="9">
<span style="color: red">
<?php echo e(session('error')); ?>
</span>
</td>
</tr>
<?php endif; ?>
<?php if($errors->any()): ?>
<tr>
<td colspan="9">
<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<span class="d-block" style="color: red">
<?php echo e($error); ?>
</span>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</td>
</tr>
<?php endif; ?>
<?php $__empty_1 = true; $__currentLoopData = $tours; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tour): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr>
<td>
<span class="avatar avatar-md avatar-square bg-light">
<?php if($tour->coverImage?->file): ?>
<img src="<?php echo e(getFileUrl($tour->coverImage->file_id)); ?>"
class="w-100 h-100"
alt="<?php echo e($tour->title); ?>">
<?php else: ?>
<img src="<?php echo e(asset('assets/admin/images/faces/DefaultAvatar.jpg')); ?>"
class="w-100 h-100"
alt="<?php echo e($tour->title); ?>">
<?php endif; ?>
</span>
</td>
<td>
<div class="fw-medium">
<?php echo e($tour->title); ?>
</div>
<?php if($tour->summary): ?>
<small class="text-muted d-inline-block text-truncate"
style="max-width: 180px;">
<?php echo e($tour->summary); ?>
</small>
<?php endif; ?>
</td>
<td>
<?php echo e($tour->originCity?->name ?? '-'); ?>
</td>
<td>
<?php echo e($tour->city?->name ?? '-'); ?>
</td>
<td>
<?php if($tour->tour_type): ?>
<span class="badge bg-success-transparent">
<?php echo e($tour->tour_type->label()); ?>
</span>
<?php else: ?>
-
<?php endif; ?>
</td>
<td>
<?php if($tour->tour_scope): ?>
<span class="badge bg-primary-transparent">
<?php echo e($tour->tour_scope->label()); ?>
</span>
<?php else: ?>
-
<?php endif; ?>
</td>
<td>
<?php echo e($tour->created_at?->toJalali()->format('H:i Y/m/d') ?? '-'); ?>
</td>
<td>
<?php echo e($tour->deleted_at?->toJalali()->format('H:i Y/m/d') ?? '-'); ?>
</td>
<td>
<div class="hstack gap-2 fs-15">
<form action="<?php echo e(route('admin.tours.trash.restore', $tour->id)); ?>"
method="POST">
<?php echo csrf_field(); ?>
<button type="submit"
class="btn btn-icon btn-sm btn-success-light"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="بازگردانی تور">
<i class="ri-arrow-go-back-line"></i>
</button>
</form>
<form action="<?php echo e(route('admin.tours.trash.forceDelete', $tour->id)); ?>"
method="POST"
onsubmit="return confirm('آیا از حذف دائمی این تور مطمئن هستید؟ این عملیات قابل بازگشت نیست.')">
<?php echo csrf_field(); ?>
<?php echo method_field('DELETE'); ?>
<button type="submit"
class="btn btn-icon btn-sm btn-danger-light"
data-bs-toggle="tooltip"
data-bs-placement="top"
title="حذف دائمی تور">
<i class="ri-delete-bin-6-line"></i>
</button>
</form>
</div>
</td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<tr>
<td colspan="9" class="text-center text-muted py-4">
توری در سطل زباله وجود ندارد.
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<div class="card-footer d-flex justify-content-center align-items-center">
<?php echo e($tours->links()); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\Desktop\airline-agency\resources\views/admin/tours/trash.blade.php ENDPATH**/ ?>
@@ -0,0 +1,414 @@
<?php $__env->startSection('breadcrumb'); ?>
<div>
<div>
<h1 class="page-title fw-medium fs-18 mb-2">ایجاد تور جدید</h1>
<div>
<nav>
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="javascript:void(0);">مدیریت تورها</a></li>
<li class="breadcrumb-item active" aria-current="page">ایجاد تور</li>
</ol>
</nav>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<form action="<?php echo e(route('admin.tours.store')); ?>" method="POST" enctype="multipart/form-data">
<?php echo csrf_field(); ?>
<div class="card custom-card">
<div class="card-header">
<div class="card-title">
مشخصات اصلی تور
</div>
</div>
<div class="card-body pt-0">
<div class="row gy-3">
<div class="col-xl-6">
<label class="form-label">عنوان تور <span class="text-danger">*</span></label>
<input
type="text"
class="form-control"
name="title"
placeholder="مثال: تور تفریحی استانبول ویژه نوروز"
value="<?php echo e(old('title')); ?>"
/>
<?php $__errorArgs = ['title'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">گستره تور <span class="text-danger">*</span></label>
<select class="form-control" name="tour_scope">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourScope::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scope): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($scope->value); ?>" <?php echo e(old('tour_scope') == $scope->value ? 'selected' : ''); ?>>
<?php echo e(method_exists($scope, 'label') ? $scope->label() : $scope->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_scope'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6" id="countryWrapper" style="display:none;">
<label class="form-label">کشور مقصد <span class="text-danger">*</span></label>
<select class="form-control" id="country_id" disabled>
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = $countries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($country->id); ?>"><?php echo e($country->name); ?></option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
</div>
<div class="col-xl-6">
<label class="form-label">نوع حمل و نقل / سفر <span class="text-danger">*</span></label>
<select class="form-control" name="tour_mode">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourMode::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mode): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($mode->value); ?>" <?php echo e(old('tour_mode') == $mode->value ? 'selected' : ''); ?>>
<?php echo e(method_exists($mode, 'label') ? $mode->label() : $mode->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_mode'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">سبک تور <span class="text-danger">*</span></label>
<select class="form-control" name="tour_type">
<option value="">یک مورد را انتخاب کنید</option>
<?php $__currentLoopData = \App\Enums\Admin\Tour\TourType::cases(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($type->value); ?>" <?php echo e(old('tour_type') == $type->value ? 'selected' : ''); ?>>
<?php echo e(method_exists($type, 'label') ? $type->label() : $type->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['tour_type'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">شهر مبدا <span class="text-danger">*</span></label>
<select class="form-control select2" name="origin_city_id">
<option value="">شهر مبدا را انتخاب کنید</option>
<?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($city->id); ?>" <?php echo e(old('origin_city_id') == $city->id ? 'selected' : ''); ?>>
<?php echo e($city->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['origin_city_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-6">
<label class="form-label">شهر مقصد <span class="text-danger">*</span></label>
<select class="form-control select2" name="destination_city_id">
<option value="">شهر مقصد را انتخاب کنید</option>
<?php $__currentLoopData = $cities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $city): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($city->id); ?>" <?php echo e(old('destination_city_id') == $city->id ? 'selected' : ''); ?>>
<?php echo e($city->name); ?>
</option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__errorArgs = ['destination_city_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-12">
<label class="form-label">خلاصه تور</label>
<textarea class="form-control" name="summary" rows="2" placeholder="توضیح کوتاه و جذاب در مورد تور..."><?php echo e(old('summary')); ?></textarea>
<?php $__errorArgs = ['summary'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-12">
<label class="form-label">توضیحات کامل و برنامه سفر</label>
<textarea class="form-control" name="description" rows="5" placeholder="جزئیات برنامه سفر، خدمات تور و توضیحات تکمیلی..."><?php echo e(old('description')); ?></textarea>
<?php $__errorArgs = ['description'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
</div>
<hr class="my-4">
<h6 class="fw-bold mb-3">اطلاعات اولین ظرفیت / زمان‌بندی حرکت</h6>
<div class="row gy-3">
<div class="col-xl-3">
<label class="form-label">تاریخ رفت (شروع)</label>
<input type="text" id="startDateInput" class="form-control" name="start_date" placeholder="تاریخ رفت را وارد کنید" value="<?php echo e(old('start_date')); ?>">
<?php $__errorArgs = ['start_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">تاریخ برگشت (پایان)</label>
<input type="text" id="endDateInput" class="form-control" name="end_date" placeholder="تاریخ برگشت را وارد کنید" value="<?php echo e(old('end_date')); ?>">
<?php $__errorArgs = ['end_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">قیمت (تومان)</label>
<input type="text" class="form-control" name="price" placeholder="مثال: ۱۵۰۰۰۰۰۰" value="<?php echo e(old('price')); ?>">
<?php $__errorArgs = ['price'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
<div class="col-xl-3">
<label class="form-label">ظرفیت مسافر</label>
<input type="number" class="form-control" name="capacity" placeholder="مثال: ۳۰" value="<?php echo e(old('capacity')); ?>">
<?php $__errorArgs = ['capacity'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
</div>
</div>
<hr class="my-4">
<h6 class="fw-bold mb-2">گالری تصاویر تور</h6>
<div
class="image-upload-wrapper d-flex flex-wrap gap-2 px-0 pt-0 mt-2"
id="imagePreviewContainer"
style="border-radius: 8px; padding: 10px;"
>
<label
id="uploadPlaceholder"
class="upload-placeholder"
for="imageInput"
style="cursor: pointer; width:150px; height:150px; display: flex; justify-content: center; align-items: center; border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center;"
>
<div>📷<br><strong>آپلود تصاویر</strong></div>
<small style="color:#999;">JPG / PNG / WEBP</small>
</label>
<input
id="imageInput"
name="images[]"
type="file"
accept=".jpg,.png,.jpeg,.webp"
multiple
style="display:none"
/>
</div>
<?php $__errorArgs = ['images'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
<span class="text-danger small d-block"><?php echo e($message); ?></span>
<?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
<?php if($errors->has('images.*')): ?>
<?php $__currentLoopData = $errors->get('images.*'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $messages): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<span class="text-danger small d-block"><?php echo e($message); ?></span>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php endif; ?>
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ثبت و ایجاد تور</button>
</div>
</div>
</form>
</div>
</div>
</div>
<?php $__env->startPush('scripts'); ?>
<script>
$(document).ready(function() {
$('#startDateInput').persianDatepicker({
format: 'YYYY/MM/DD HH:mm',
timePicker: {
enabled: true,
meridiem: {
enabled: false
}
},
autoClose: false,
initialValue: false,
minDate: new persianDate().valueOf(),
toolbox: {
calendarSwitch: {
enabled: false
}
}
});
$('#endDateInput').persianDatepicker({
format: 'YYYY/MM/DD HH:mm',
timePicker: {
enabled: true,
meridiem: {
enabled: false
}
},
autoClose: false,
initialValue: false,
minDate: new persianDate().valueOf(),
toolbox: {
calendarSwitch: {
enabled: false
}
}
});
const originalDestHtml = $('select[name="destination_city_id"]').html();
function toggleScopeUI() {
const scope = $('select[name="tour_scope"]').val();
if (scope === '1') {
$('#countryWrapper').show();
$('#country_id').prop('disabled', false);
} else {
$('#countryWrapper').hide();
$('#country_id').prop('disabled', true).val('');
$('select[name="destination_city_id"]').html(originalDestHtml).trigger('change');
}
}
$('select[name="tour_scope"]').on('change', toggleScopeUI);
toggleScopeUI();
$('#country_id').on('change', function () {
const countryId = $(this).val();
if (!countryId) return;
$.get(`/admin/tours/cities-by-country/${countryId}`, function (cities) {
let options = '<option value="">شهر را انتخاب کنید</option>';
cities.forEach(function (city) {
options += `<option value="${city.id}">${city.name}</option>`;
});
$('select[name="destination_city_id"]').html(options).trigger('change');
}).fail(function () {
alert('خطا در دریافت لیست شهرهای این کشور');
});
});
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\ASUS\Desktop\airline-agency\resources\views/admin/tours/create.blade.php ENDPATH**/ ?>