77 lines
1.6 KiB
PHP
77 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Flight;
|
|
use Illuminate\Http\Request;
|
|
|
|
class BookingController extends Controller
|
|
{
|
|
public function flight(Flight $flight)
|
|
{
|
|
// فقط پرواز فعال
|
|
if ((int)$flight->status !== 1) {
|
|
abort(404);
|
|
}
|
|
|
|
$flight->load([
|
|
'travelType',
|
|
'origin',
|
|
'destination',
|
|
]);
|
|
|
|
return view('account.bookings', compact('flight'));
|
|
}
|
|
|
|
public function storeFlight(Request $request, Flight $flight)
|
|
{
|
|
// بررسی فعال بودن پرواز
|
|
if ((int) $flight->status !== 1) {
|
|
abort(404);
|
|
}
|
|
|
|
// اعتبارسنجی
|
|
$validated = $request->validate([
|
|
'first_name' => [
|
|
'required',
|
|
'string',
|
|
'max:100',
|
|
],
|
|
|
|
'last_name' => [
|
|
'required',
|
|
'string',
|
|
'max:100',
|
|
],
|
|
|
|
'national_code' => [
|
|
'required',
|
|
'string',
|
|
'max:20',
|
|
],
|
|
|
|
'phone' => [
|
|
'required',
|
|
'string',
|
|
'max:20',
|
|
],
|
|
|
|
'passengers' => [
|
|
'required',
|
|
'integer',
|
|
'min:1',
|
|
'max:10',
|
|
],
|
|
]);
|
|
|
|
|
|
// فعلاً برای تست
|
|
return redirect()
|
|
->route('flights.show', $flight)
|
|
->with(
|
|
'success',
|
|
'درخواست رزرو پرواز با موفقیت ثبت شد.'
|
|
);
|
|
}
|
|
}
|