605 lines
24 KiB
PHP
605 lines
24 KiB
PHP
@extends('admin.layouts.app')
|
|
|
|
@section('breadcrumb')
|
|
<div>
|
|
<h1 class="page-title fw-medium fs-18 mb-2">
|
|
ویرایش پرواز
|
|
</h1>
|
|
|
|
<nav>
|
|
<ol class="breadcrumb mb-0">
|
|
|
|
<li class="breadcrumb-item">
|
|
<a href="{{ route('admin.flights.index') }}">
|
|
مدیریت پروازها
|
|
</a>
|
|
</li>
|
|
|
|
<li class="breadcrumb-item active" aria-current="page">
|
|
ویرایش پرواز
|
|
</li>
|
|
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
@endsection
|
|
|
|
|
|
@section('content')
|
|
|
|
<div class="container-fluid pt-4">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xl-12">
|
|
|
|
<form
|
|
action="{{ route('admin.flights.update', $flight) }}"
|
|
method="POST"
|
|
enctype="multipart/form-data"
|
|
>
|
|
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
@error('general')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
|
|
<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">
|
|
عنوان پرواز
|
|
</label>
|
|
|
|
<input
|
|
type="text"
|
|
class="form-control"
|
|
name="title"
|
|
placeholder="عنوان پرواز را وارد کنید"
|
|
value="{{ old('title', $flight->title) }}"
|
|
>
|
|
|
|
@error('title')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- ایرلاین --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
ایرلاین
|
|
</label>
|
|
|
|
<select
|
|
class="form-control"
|
|
name="airline_id"
|
|
>
|
|
|
|
<option value="">
|
|
یک ایرلاین انتخاب کنید
|
|
</option>
|
|
|
|
@foreach($airlines as $airline)
|
|
|
|
<option
|
|
value="{{ $airline->id }}"
|
|
@selected(
|
|
old(
|
|
'airline_id',
|
|
$flight->airline_id
|
|
) == $airline->id
|
|
)
|
|
>
|
|
{{ $airline->name }}
|
|
</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
@error('airline_id')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- فرودگاه مبدأ --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
فرودگاه مبدأ
|
|
</label>
|
|
|
|
<select
|
|
class="form-control"
|
|
name="departure_airport_id"
|
|
>
|
|
|
|
<option value="">
|
|
فرودگاه مبدأ را انتخاب کنید
|
|
</option>
|
|
|
|
@foreach($airports as $airport)
|
|
|
|
<option
|
|
value="{{ $airport->id }}"
|
|
@selected(
|
|
old(
|
|
'departure_airport_id',
|
|
$flight->departure_airport_id
|
|
) == $airport->id
|
|
)
|
|
>
|
|
{{ $airport->city?->name }}
|
|
-
|
|
{{ $airport->name }}
|
|
</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
@error('departure_airport_id')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- فرودگاه مقصد --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
فرودگاه مقصد
|
|
</label>
|
|
|
|
<select
|
|
class="form-control"
|
|
name="arrival_aiport_id"
|
|
>
|
|
|
|
<option value="">
|
|
فرودگاه مقصد را انتخاب کنید
|
|
</option>
|
|
|
|
@foreach($airports as $airport)
|
|
|
|
<option
|
|
value="{{ $airport->id }}"
|
|
@selected(
|
|
old(
|
|
'arrival_aiport_id',
|
|
$flight->arrival_aiport_id
|
|
) == $airport->id
|
|
)
|
|
>
|
|
{{ $airport->city?->name }}
|
|
-
|
|
{{ $airport->name }}
|
|
</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
@error('arrival_aiport_id')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- نوع پرواز --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
نوع پرواز
|
|
</label>
|
|
|
|
<select
|
|
class="form-control"
|
|
name="flight_type"
|
|
>
|
|
|
|
<option value="">
|
|
نوع پرواز را انتخاب کنید
|
|
</option>
|
|
|
|
<option
|
|
value="{{ \App\Enums\FlightType::DEPARTURE->value }}"
|
|
@selected(
|
|
old(
|
|
'flight_type',
|
|
$flight->flight_type->value
|
|
) ==
|
|
\App\Enums\FlightType::DEPARTURE->value
|
|
)
|
|
>
|
|
یکطرفه
|
|
</option>
|
|
|
|
<option
|
|
value="{{ \App\Enums\FlightType::RETURN->value }}"
|
|
@selected(
|
|
old(
|
|
'flight_type',
|
|
$flight->flight_type->value
|
|
) ==
|
|
\App\Enums\FlightType::RETURN->value
|
|
)
|
|
>
|
|
برگشت
|
|
</option>
|
|
|
|
<option
|
|
value="{{ \App\Enums\FlightType::ROUNDTRIP->value }}"
|
|
@selected(
|
|
old(
|
|
'flight_type',
|
|
$flight->flight_type->value
|
|
) ==
|
|
\App\Enums\FlightType::ROUNDTRIP->value
|
|
)
|
|
>
|
|
رفت و برگشت
|
|
</option>
|
|
|
|
</select>
|
|
|
|
@error('flight_type')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- وضعیت --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
وضعیت
|
|
</label>
|
|
|
|
<select
|
|
class="form-control"
|
|
name="status"
|
|
>
|
|
|
|
<option value="">
|
|
وضعیت را انتخاب کنید
|
|
</option>
|
|
|
|
<option
|
|
value="{{ \App\Enums\FlightStatus::ENABLE->value }}"
|
|
@selected(
|
|
old(
|
|
'status',
|
|
$flight->status->value
|
|
) ==
|
|
\App\Enums\FlightStatus::ENABLE->value
|
|
)
|
|
>
|
|
فعال
|
|
</option>
|
|
|
|
<option
|
|
value="{{ \App\Enums\FlightStatus::DISABLE->value }}"
|
|
@selected(
|
|
old(
|
|
'status',
|
|
$flight->status->value
|
|
) ==
|
|
\App\Enums\FlightStatus::DISABLE->value
|
|
)
|
|
>
|
|
غیرفعال
|
|
</option>
|
|
|
|
</select>
|
|
|
|
@error('status')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- زمان حرکت --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
زمان حرکت
|
|
</label>
|
|
|
|
<input
|
|
type="text"
|
|
class="form-control"
|
|
name="departure_time_jalali"
|
|
id="departure_time_jalali"
|
|
data-jdp
|
|
data-jdp-target-value-input="#departure_time_gregorian"
|
|
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')
|
|
: ''
|
|
) }}"
|
|
>
|
|
|
|
<input
|
|
type="hidden"
|
|
name="departure_time"
|
|
id="departure_time_gregorian"
|
|
value="{{ old(
|
|
'departure_time',
|
|
optional($flight->departure_time)->format('Y-m-d H:i:s')
|
|
) }}"
|
|
>
|
|
|
|
@error('departure_time')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- قیمت --}}
|
|
<div class="col-xl-6">
|
|
|
|
<label class="form-label">
|
|
قیمت
|
|
</label>
|
|
|
|
<input
|
|
type="number"
|
|
class="form-control"
|
|
name="price"
|
|
placeholder="قیمت را وارد کنید"
|
|
value="{{ old('price', $flight->price) }}"
|
|
>
|
|
|
|
@error('price')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- توضیحات --}}
|
|
<div class="col-xl-12">
|
|
|
|
<label class="form-label">
|
|
توضیحات
|
|
</label>
|
|
|
|
<textarea
|
|
class="form-control"
|
|
name="summary"
|
|
rows="4"
|
|
placeholder="توضیحات پرواز را وارد کنید"
|
|
>{{ old('summary', $flight->summary) }}</textarea>
|
|
|
|
@error('summary')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
{{-- تصویر پرواز --}}
|
|
<div class="col-xl-12">
|
|
|
|
<label class="form-label">
|
|
تصویر پرواز
|
|
</label>
|
|
|
|
<div
|
|
class="d-flex align-items-center gap-3"
|
|
>
|
|
|
|
{{-- تصویر فعلی --}}
|
|
<div
|
|
style="
|
|
width:150px;
|
|
height:150px;
|
|
"
|
|
>
|
|
|
|
<img
|
|
id="flightImagePreview"
|
|
src="{{ $flight->file?->path
|
|
? asset('storage/' . $flight->file->path)
|
|
: asset('assets/img/flight/01.jpg')
|
|
}}"
|
|
alt="{{ $flight->title }}"
|
|
class="w-100 h-100 rounded"
|
|
style="object-fit:cover;"
|
|
>
|
|
|
|
</div>
|
|
|
|
|
|
{{-- انتخاب عکس جدید --}}
|
|
<label
|
|
for="imageInput"
|
|
style="
|
|
cursor:pointer;
|
|
width:150px;
|
|
height:150px;
|
|
display:flex;
|
|
justify-content:center;
|
|
align-items:center;
|
|
border:2px dashed #ccc;
|
|
border-radius:8px;
|
|
text-align:center;
|
|
"
|
|
>
|
|
|
|
<div>
|
|
|
|
📷
|
|
<br>
|
|
|
|
<strong>
|
|
تغییر تصویر
|
|
</strong>
|
|
|
|
<br>
|
|
|
|
<small style="color:#999;">
|
|
JPG / PNG / JPEG / WEBP
|
|
</small>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
|
|
<input
|
|
id="imageInput"
|
|
name="image"
|
|
type="file"
|
|
accept=".jpg,.jpeg,.png,.webp"
|
|
style="display:none;"
|
|
>
|
|
|
|
</div>
|
|
|
|
@error('image')
|
|
<span class="text-danger">
|
|
{{ $message }}
|
|
</span>
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="card-footer text-end">
|
|
|
|
<button
|
|
type="submit"
|
|
class="btn btn-primary"
|
|
>
|
|
ذخیره تغییرات
|
|
</button>
|
|
|
|
<a
|
|
href="{{ route('admin.flights.index') }}"
|
|
class="btn btn-light"
|
|
>
|
|
انصراف
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
@push('js')
|
|
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://unpkg.com/@majidh1/jalalidatepicker/dist/jalalidatepicker.min.css"
|
|
>
|
|
|
|
<script
|
|
src="https://unpkg.com/@majidh1/jalalidatepicker/dist/jalalidatepicker.min.js">
|
|
</script>
|
|
|
|
|
|
<script>
|
|
|
|
jalaliDatepicker.startWatch({
|
|
date: true,
|
|
time: true,
|
|
hasSecond: false,
|
|
targetValueInput: 'attr',
|
|
targetValueType: 'attr'
|
|
});
|
|
|
|
document
|
|
.getElementById('imageInput')
|
|
.addEventListener('change', function (event) {
|
|
|
|
const file = event.target.files[0];
|
|
|
|
if (!file) {
|
|
return;
|
|
}
|
|
|
|
const preview =
|
|
document.getElementById('flightImagePreview');
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
preview.src = e.target.result;
|
|
};
|
|
|
|
reader.readAsDataURL(file);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@endpush
|
|
|
|
@endsection
|