git commit "add flight image upload and update support"

This commit is contained in:
2026-08-18 17:58:02 +03:30
parent 0722cf3120
commit 62a95c411b
15 changed files with 896 additions and 26 deletions
@@ -60,14 +60,15 @@
<h3>
{{ $reservation->reservable?->name ?? 'پرواز حذف شده' }}
{{ $reservation->reservable?->airline ?? 'پرواز حذف شده' }}
</h3>
<p>
پرواز
{{ $reservation->reservable?->origin }}
-
{{ $reservation->reservable?->destination }}
</p>
@endif
+224 -3
View File
@@ -1,3 +1,224 @@
<div>
<!-- Live as if you were to die tomorrow. Learn as if you were to live forever. - Mahatma Gandhi -->
</div>
@extends('admin.layouts.app')
@section('content')
<div class="container">
<h4 class="mb-4">
ثبت پرواز جدید
</h4>
<form action="{{ route('admin.flights.store') }}"
method="POST"
enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-md-6 mb-3">
<label>
ایرلاین
</label>
<input type="text"
name="airline"
class="form-control"
value="{{ old('airline') }}">
@error('airline')
<small class="text-danger">
{{ $message }}
</small>
@enderror
</div>
<div class="col-md-6 mb-3">
<label>
شماره پرواز
</label>
<input type="text"
name="flight_number"
class="form-control"
value="{{ old('flight_number') }}">
@error('flight_number')
<small class="text-danger">
{{ $message }}
</small>
@enderror
</div>
<div class="col-md-6 mb-3">
<label>
مبدا
</label>
<input type="text"
name="origin"
class="form-control"
value="{{ old('origin') }}">
</div>
<div class="col-md-6 mb-3">
<label>
مقصد
</label>
<input type="text"
name="destination"
class="form-control"
value="{{ old('destination') }}">
</div>
<div class="col-md-4 mb-3">
<label>
نوع پرواز
</label>
<select name="type" class="form-control">
<option value="0">داخلی</option>
<option value="2">خارجی</option>
<option value="3">چارتر</option>
</select>
</div>
<div class="col-md-4 mb-3">
<label>
تاریخ حرکت
</label>
<input type="date"
name="departure_date"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
کلاس پرواز
</label>
<input type="text"
name="flight_class"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
ظرفیت
</label>
<input type="number"
name="capacity"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
قیمت
</label>
<input type="number"
name="price"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
عکس
</label>
<input type="file"
name="image"
class="form-control">
</div>
<div class="col-md-4 mb-3">
<label>
وضعیت
</label>
<select name="status"
class="form-control">
<option value="1">
فعال
</option>
<option value="0">
پیش نویس
</option>
<option value="2">
غیرفعال
</option>
<option value="3">
تمام شده
</option>
<option value="4">
لغو شده
</option>
</select>
</div>
</div>
<button class="btn btn-primary">
ذخیره
</button>
</form>
</div>
@endsection
+241 -3
View File
@@ -1,3 +1,241 @@
<div>
<!-- Let all your things have their places; let each part of your business have its time. - Benjamin Franklin -->
</div>
@extends('admin.layouts.app')
@section('content')
<div class="container">
<h4 class="mb-4">
ویرایش پرواز
</h4>
<form action="{{ route('admin.flights.update', $flight->id) }}"
method="POST"
enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="row">
<div class="col-md-6 mb-3">
<label>نام ایرلاین</label>
<input type="text"
name="airline"
class="form-control"
value="{{ old('airline', $flight->airline) }}">
@error('airline')
<small class="text-danger">
{{ $message }}
</small>
@enderror
</div>
<div class="col-md-6 mb-3">
<label>شماره پرواز</label>
<input type="text"
name="flight_number"
class="form-control"
value="{{ old('flight_number', $flight->flight_number) }}">
</div>
<div class="col-md-6 mb-3">
<label>مبدا</label>
<input type="text"
name="origin"
class="form-control"
value="{{ old('origin', $flight->origin) }}">
</div>
<div class="col-md-6 mb-3">
<label>مقصد</label>
<input type="text"
name="destination"
class="form-control"
value="{{ old('destination', $flight->destination) }}">
</div>
<div class="col-md-4 mb-3">
<label>تاریخ حرکت</label>
<input type="date"
name="departure_date"
class="form-control"
value="{{ old('departure_date', $flight->departure_date) }}">
</div>
<div class="col-md-4 mb-3">
<label>ساعت حرکت</label>
<input type="time"
name="departure_time"
class="form-control"
value="{{ old('departure_time', $flight->departure_time) }}">
</div>
<div class="col-md-4 mb-3">
<label>ساعت رسیدن</label>
<input type="time"
name="arrival_time"
class="form-control"
value="{{ old('arrival_time', $flight->arrival_time) }}">
</div>
<div class="col-md-4 mb-3">
<label>کلاس پرواز</label>
<input type="text"
name="flight_class"
class="form-control"
value="{{ old('flight_class', $flight->flight_class) }}">
</div>
<div class="col-md-4 mb-3">
<label>ظرفیت</label>
<input type="number"
name="capacity"
class="form-control"
value="{{ old('capacity', $flight->capacity) }}">
</div>
<div class="col-md-4 mb-3">
<label>قیمت</label>
<input type="number"
name="price"
class="form-control"
value="{{ old('price', $flight->price) }}">
</div>
<div class="col-md-6 mb-3">
<label>وضعیت</label>
<select name="status" class="form-control">
<option value="0"
{{ $flight->status == 0 ? 'selected':'' }}>
پیش نویس
</option>
<option value="1"
{{ $flight->status == 1 ? 'selected':'' }}>
فعال
</option>
<option value="2"
{{ $flight->status == 2 ? 'selected':'' }}>
غیرفعال
</option>
<option value="3"
{{ $flight->status == 3 ? 'selected':'' }}>
تمام شده
</option>
<option value="4"
{{ $flight->status == 4 ? 'selected':'' }}>
لغو شده
</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label>تصویر</label>
<input type="file"
name="image"
class="form-control">
@if($flight->image)
<img src="{{ asset('storage/'.$flight->image) }}"
width="120"
class="mt-2">
@endif
</div>
</div>
<button class="btn btn-primary">
ذخیره تغییرات
</button>
<a href="{{ route('admin.flights.index') }}"
class="btn btn-secondary">
بازگشت
</a>
</form>
</div>
@endsection
+271 -3
View File
@@ -1,3 +1,271 @@
<div>
<!-- Simplicity is the essence of happiness. - Cedric Bledsoe -->
</div>
@extends('admin.layouts.app')
@section('content')
<div class="container">
<div class="d-flex justify-content-between mb-4">
<h4>
مدیریت پروازها
</h4>
<a href="{{ route('admin.flights.create') }}"
class="btn btn-primary">
ثبت پرواز جدید
</a>
</div>
<form method="GET"
action="{{ route('admin.flights.index') }}"
class="mb-3">
<div class="row">
<div class="col-md-4">
<input type="text"
name="search"
class="form-control"
placeholder="جستجو..."
value="{{ request('search') }}">
</div>
<div class="col-md-3">
<select name="type"
class="form-control">
<option value="">
همه انواع
</option>
<option value="internal"
@selected(request('type')=='internal')>
داخلی
</option>
<option value="external"
@selected(request('type')=='external')>
خارجی
</option>
<option value="charter"
@selected(request('type')=='charter')>
چارتر
</option>
</select>
</div>
<div class="col-md-3">
<select name="sort"
class="form-control">
<option value="newest">
جدیدترین
</option>
<option value="price_asc">
ارزان‌ترین
</option>
<option value="price_desc">
گران‌ترین
</option>
</select>
</div>
<div class="col-md-2">
<button class="btn btn-dark w-100">
اعمال
</button>
</div>
</div>
</form>
<table class="table table-bordered text-center">
<thead>
<tr>
<th>
#
</th>
<th>
ایرلاین
</th>
<th>
شماره پرواز
</th>
<th>
مسیر
</th>
<th>
نوع
</th>
<th>
قیمت
</th>
<th>
وضعیت
</th>
<th>
عملیات
</th>
</tr>
</thead>
<tbody>
@forelse($flights as $flight)
<tr>
<td>
{{ $loop->iteration }}
</td>
<td>
{{ $flight->airline }}
</td>
<td>
{{ $flight->flight_number }}
</td>
<td>
{{ $flight->origin }}
-
{{ $flight->destination }}
</td>
<td>
@switch($flight->type->value)
@case('internal')
داخلی
@break
@case('external')
خارجی
@break
@case('charter')
چارتر
@break
@endswitch
</td>
<td>
{{ number_format($flight->price) }}
</td>
<td>
{{ $flight->status }}
</td>
<td>
<a href="{{ route('admin.flights.edit',$flight) }}"
class="btn btn-warning btn-sm">
ویرایش
</a>
<form action="{{ route('admin.flights.destroy',$flight) }}"
method="POST"
class="d-inline">
@csrf
@method('DELETE')
<button class="btn btn-danger btn-sm"
onclick="return confirm('حذف شود؟')">
حذف
</button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="8">
موردی یافت نشد
</td>
</tr>
@endforelse
</tbody>
</table>
{{ $flights->links() }}
</div>
@endsection