From c2fba2000c94a1ec75ecf06bdee882da05a4c619 Mon Sep 17 00:00:00 2001 From: Bahar Date: Mon, 17 Aug 2026 13:10:16 +0330 Subject: [PATCH] fix:edit booking and booking passengers model --- app/Models/Booking.php | 17 +++++++++++++---- app/Models/BookingPassenger.php | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 3d5d5a8..5024512 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -6,12 +6,13 @@ namespace App\Models; +use App\Enums\BookingStatus; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; /** * Class Booking - * + * * @property int $id * @property int $user_id * @property int|null $flight_id @@ -23,7 +24,7 @@ use Illuminate\Database\Eloquent\Model; * @property Carbon $created_at * @property int $status * @property Carbon $updated_at - * + * * @property User $user * @property Flight|null $flight * @property TourDate|null $tourDate @@ -33,6 +34,7 @@ use Illuminate\Database\Eloquent\Model; class Booking extends Model { protected $table = 'bookings'; + public $timestamps = false; public static $snakeAttributes = false; protected $casts = [ @@ -42,7 +44,8 @@ class Booking extends Model 'adult_count' => 'int', 'child_count' => 'int', 'total_price' => 'int', - 'status' => 'int' + 'status' => BookingStatus::class, + 'created_at' => 'datetime' ]; protected $fillable = [ @@ -53,7 +56,9 @@ class Booking extends Model 'child_count', 'total_price', 'tracking_code', - 'status' + 'status', + 'created_at', + 'updated_at' ]; public function user() @@ -70,4 +75,8 @@ class Booking extends Model { return $this->belongsTo(TourDate::class); } + public function passengers() + { + return $this->hasMany(BookingPassenger::class); + } } diff --git a/app/Models/BookingPassenger.php b/app/Models/BookingPassenger.php index f507631..30baeac 100644 --- a/app/Models/BookingPassenger.php +++ b/app/Models/BookingPassenger.php @@ -6,12 +6,13 @@ namespace App\Models; +use App\Enums\PassengerType; use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; /** * Class BookingPassenger - * + * * @property int $id * @property int $booking_id * @property string $first_name @@ -27,12 +28,14 @@ use Illuminate\Database\Eloquent\Model; class BookingPassenger extends Model { protected $table = 'booking_passengers'; + public $timestamps = false; public static $snakeAttributes = false; protected $casts = [ 'booking_id' => 'int', - 'passenger_type' => 'int', - 'birth_date' => 'datetime' + 'birth_date' => 'datetime', + 'passenger_type' => PassengerType::class, + 'created_ar' => 'datetime' ]; protected $fillable = [ @@ -41,6 +44,12 @@ class BookingPassenger extends Model 'last_name', 'national_code', 'passenger_type', - 'birth_date' + 'birth_date', + 'created_at', + 'updated_at' ]; + public function booking() + { + return $this->belongsTo(Booking::class); + } }