fix: update tour management

This commit is contained in:
2026-08-17 19:53:12 +03:30
parent 81d2aa1acb
commit 123b43fb38
7 changed files with 358 additions and 29 deletions
+62 -3
View File
@@ -1,3 +1,62 @@
<div>
<!-- It always seems impossible until it is done. - Nelson Mandela -->
</div>
@extends('admin.layouts.app')
@section('content')
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow">
<div class="card-header bg-primary text-white">
<h4 class="mb-0">ثبت تور جدید</h4>
</div>
<div class="card-body">
<form action="{{ route('admin.tours.store') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="mb-3">
<label class="form-label">عنوان تور</label>
<input type="text" name="title"
class="form-control @error('title') is-invalid @enderror"
value="{{ old('title') }}">
@error('title')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="mb-3">
<label class="form-label">توضیحات</label>
<textarea name="description"
class="form-control @error('description') is-invalid @enderror"
rows="4">{{ old('description') }}</textarea>
@error('description')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">قیمت</label>
<input type="number" name="price"
class="form-control @error('price') is-invalid @enderror"
value="{{ old('price') }}">
@error('price')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
<div class="col-md-6 mb-3">
<label class="form-label">تصویر تور</label>
<input type="file" name="image"
class="form-control @error('image') is-invalid @enderror">
@error('image')
<div class="invalid-feedback">{{ $message }}</div> @enderror
</div>
</div>
<div class="mt-4 d-flex justify-content-between">
<a href="{{ route('admin.tours.index') }}" class="btn btn-secondary">انصراف</a>
<button type="submit" class="btn btn-success">ذخیره تور</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
+86 -3
View File
@@ -1,3 +1,86 @@
<div>
<!-- It is not the man who has too little, but the man who craves more, that is poor. - Seneca -->
</div>
@extends('admin.layouts.app')
@section('content')
<div class="container-fluid">
<div class="d-flex justify-content-between align-items-center mb-4">
<h4>ویرایش تور: {{ $tour->title }}</h4>
<a href="{{ route('admin.tours.index') }}" class="btn btn-secondary">بازگشت</a>
</div>
@if ($errors->any())
<div class="alert alert-danger">
<ul class="mb-0">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="card border-0 shadow-sm">
<div class="card-body">
<form action="{{ route('admin.tours.update', $tour->id) }}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<!-- عنوان -->
<div class="col-md-6 mb-3">
<label class="form-label">عنوان تور</label>
<input type="text" name="title" class="form-control"
value="{{ old('title', $tour->title) }}" required>
</div>
<!-- نوع سفر -->
<div class="col-md-6 mb-3">
<label class="form-label">نوع سفر</label>
<select name="travel_type_id" class="form-select">
@foreach($travelTypes as $type)
<option
value="{{ $type->id }}" {{ $tour->travel_type_id == $type->id ? 'selected' : '' }}>
{{ $type->name }}
</option>
@endforeach
</select>
</div>
<!-- قیمت -->
<div class="col-md-4 mb-3">
<label class="form-label">قیمت (تومان)</label>
<input type="number" name="price" class="form-control"
value="{{ old('price', $tour->price) }}">
</div>
<!-- ظرفیت -->
<div class="col-md-4 mb-3">
<label class="form-label">ظرفیت</label>
<input type="number" name="capacity" class="form-control"
value="{{ old('capacity', $tour->capacity) }}">
</div>
<!-- وضعیت -->
<div class="col-md-4 mb-3">
<label class="form-label">وضعیت</label>
<select name="status" class="form-select">
<option value="0" {{ $tour->status == 0 ? 'selected' : '' }}>پیش‌نویس</option>
<option value="1" {{ $tour->status == 1 ? 'selected' : '' }}>فعال</option>
<option value="2" {{ $tour->status == 2 ? 'selected' : '' }}>منتشر شده</option>
</select>
</div>
<!-- توضیحات -->
<div class="col-12 mb-3">
<label class="form-label">توضیحات</label>
<textarea name="description" class="form-control"
rows="5">{{ old('description', $tour->description) }}</textarea>
</div>
</div>
<div class="d-flex justify-content-end">
<button type="submit" class="btn btn-primary px-4">ذخیره تغییرات</button>
</div>
</form>
</div>
</div>
</div>
@endsection
+61 -3
View File
@@ -1,3 +1,61 @@
<div>
<!-- Nothing worth having comes easy. - Theodore Roosevelt -->
</div>
@extends('admin.layouts.app') {{-- فرض بر وجود لایوت ادمین --}}
@section('content')
<div class="container mt-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h2>مدیریت تورها</h2>
<a href="{{ route('admin.tours.create') }}" class="btn btn-primary">افزودن تور جدید</a>
</div>
@if(session('success'))
<div class="alert alert-success">{{ session('success') }}</div>
@endif
<div class="card shadow">
<div class="card-body">
<table class="table table-hover">
<thead class="table-light">
<tr>
<th>تصویر</th>
<th>عنوان تور</th>
<th>قیمت (تومان)</th>
<th>عملیات</th>
</tr>
</thead>
<tbody>
@forelse($tours as $tour)
<tr>
<td>
<img src="{{ asset('storage/' . ($tour->image ?? 'default.jpg')) }}" width="60" class="rounded">
</td>
<td>{{ $tour->title }}</td>
<td>{{ number_format($tour->price) }}</td>
<td>
<div class="btn-group" role="group">
<a href="{{ route('admin.tours.show', $tour->id) }}" class="btn btn-sm btn-info text-white">مشاهده</a>
<a href="{{ route('admin.tours.edit', $tour->id) }}" class="btn btn-sm btn-warning text-white">ویرایش</a>
<form action="{{ route('admin.tours.destroy', $tour->id) }}" method="POST" onsubmit="return confirm('آیا مطمئن هستید؟')">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger">حذف</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="text-center">هیچ توری یافت نشد.</td>
</tr>
@endforelse
</tbody>
</table>
{{-- بخش بسیار مهم برای آزمون: نمایش لینک‌های صفحه‌بندی --}}
<div class="d-flex justify-content-center mt-3">
{{ $tours->links() }}
</div>
</div>
</div>
</div>
@endsection
+80 -3
View File
@@ -1,3 +1,80 @@
<div>
<!-- Simplicity is an acquired taste. - Katharine Gerould -->
</div>
@extends('admin.layouts.app')
@section('title', 'جزئیات تور')
@section('content')
{{-- هدر صفحه --}}
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="mb-0">
<i class="bi bi-airplane me-2"></i>
جزئیات تور
</h3>
<div>
<a href="{{ route('admin.tours.edit', $tour) }}" class="btn btn-warning">
<i class="bi bi-pencil-square me-1"></i>ویرایش
</a>
<a href="{{ route('admin.tours.index') }}" class="btn btn-secondary">
<i class="bi bi-arrow-right me-1"></i>بازگشت به لیست
</a>
</div>
</div>
{{-- کارت اطلاعات --}}
<div class="card shadow-sm border-0">
<div class="card-header bg-white py-3">
<span class="fw-bold">{{ $tour->title }}</span>
</div>
<div class="card-body">
<table class="table table-bordered table-striped align-middle mb-0">
<tbody>
<tr>
<th class="bg-light" style="width: 200px;">عنوان</th>
<td>{{ $tour->title }}</td>
</tr>
<tr>
<th class="bg-light">مبدا</th>
<td>{{ $tour->origin }}</td>
</tr>
<tr>
<th class="bg-light">مقصد</th>
<td>{{ $tour->destination }}</td>
</tr>
<tr>
<th class="bg-light">تاریخ شروع</th>
<td>{{ \Carbon\Carbon::parse($tour->start_date)->format('Y/m/d') }}</td>
</tr>
<tr>
<th class="bg-light">تاریخ پایان</th>
<td>{{ \Carbon\Carbon::parse($tour->end_date)->format('Y/m/d') }}</td>
</tr>
<tr>
<th class="bg-light">قیمت</th>
<td>{{ number_format($tour->price) }} <small>تومان</small></td>
</tr>
<tr>
<th class="bg-light">ظرفیت</th>
<td>{{ $tour->capacity }} <small>نفر</small></td>
</tr>
<tr>
<th class="bg-light">وضعیت</th>
<td>
@if($tour->status == 0)
<span class="badge bg-danger">غیرفعال</span>
@elseif($tour->status == 1)
<span class="badge bg-warning text-dark">فعال / پیش‌نویس</span>
@elseif($tour->status == 2)
<span class="badge bg-success">منتشرشده</span>
@else
<span class="badge bg-secondary">نامشخص</span>
@endif
</td>
</tr>
<tr>
<th class="bg-light">توضیحات</th>
<td>{!! nl2br(e($tour->description)) !!}</td>
</tr>
</tbody>
</table>
</div>
</div>
@endsection