fix:edit models

This commit is contained in:
2026-08-17 13:13:45 -07:00
parent 5e61ca4289
commit 571c933476
5 changed files with 54 additions and 20 deletions
+13 -2
View File
@@ -14,10 +14,11 @@ use Illuminate\Database\Eloquent\Model;
*
* @property int $id
* @property string $name
* @property string $city
* @property int $city_id
* @property string $country
* @property string $code
*
* @property City $city
* @property Collection|Flight[] $flights
*
* @package App\Models
@@ -26,14 +27,24 @@ class Airport extends Model
{
protected $table = 'airports';
public $timestamps = false;
public static $snakeAttributes = false;
protected $casts = [
'city_id' => 'int'
];
protected $fillable = [
'name',
'city',
'city_id',
'country',
'code'
];
public function city()
{
return $this->belongsTo(City::class);
}
public function flights()
{
return $this->hasMany(Flight::class, 'departure_airport_id');
+13 -6
View File
@@ -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 $flight_id
@@ -23,8 +24,8 @@ use Illuminate\Database\Eloquent\Model;
* @property int $status
* @property Carbon $created_ar
* @property Carbon $updated_at
*
* @property Flight $flight
*
* @property Flight $flights
* @property TourDate $tour_date
* @property User $user
*
@@ -42,8 +43,8 @@ class Booking extends Model
'adult_count' => 'int',
'child_count' => 'int',
'total_price' => 'int',
'status' => 'int',
'created_ar' => 'datetime'
'status' => BookingStatus::class,
'created_at' => 'datetime'
];
protected $fillable = [
@@ -55,7 +56,8 @@ class Booking extends Model
'total_price',
'tracking_code',
'status',
'created_ar'
'created_at',
'updated_at'
];
public function flight()
@@ -72,4 +74,9 @@ class Booking extends Model
{
return $this->belongsTo(User::class);
}
public function passengers()
{
return $this->hasMany(BookingPassenger::class);
}
}
+11 -4
View File
@@ -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
@@ -32,8 +33,8 @@ class BookingPassenger extends Model
protected $casts = [
'booking_id' => 'int',
'birth_date' => 'datetime',
'passenger_type' => 'int',
'created_ar' => 'datetime'
'passenger_type' => PassengerType::class,
'created_at' => 'datetime'
];
protected $fillable = [
@@ -43,6 +44,12 @@ class BookingPassenger extends Model
'national_code',
'birth_date',
'passenger_type',
'created_ar'
'created_at',
'updated_at'
];
public function booking()
{
return $this->belongsTo(Booking::class);
}
}
+11 -5
View File
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Tour
*
*
* @property int $id
* @property string $title
* @property string $summary
@@ -22,9 +22,9 @@ use Illuminate\Database\Eloquent\Model;
* @property int|null $file_id
* @property int $duration
* @property int $status
* @property Carbon $created_ar
* @property Carbon $created_at
* @property Carbon $updated_at
*
*
* @property File|null $file
* @property Collection|TourDate[] $tour_dates
*
@@ -38,8 +38,9 @@ class Tour extends Model
protected $casts = [
'file_id' => 'int',
'duration' => 'int',
'views' => 'int',
'status' => 'int',
'created_ar' => 'datetime'
'created_at' => 'datetime'
];
protected $fillable = [
@@ -50,8 +51,9 @@ class Tour extends Model
'destination',
'file_id',
'duration',
'views',
'status',
'created_ar'
'created_at'
];
public function file()
@@ -63,4 +65,8 @@ class Tour extends Model
{
return $this->hasMany(TourDate::class);
}
public function comments()
{
return $this->hasMany(Comment::class, 'tour_id');
}
}
+6 -3
View File
@@ -6,6 +6,9 @@
namespace App\Models;
use App\Enums\UserGenderStatus;
use App\Enums\UserMaritalStatus;
use App\Enums\UserStatus;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -47,12 +50,12 @@ class User extends Authenticated
public static $snakeAttributes = false;
protected $casts = [
'gender' => 'int',
'marital_status' => 'int',
'gender' => UserGenderStatus::class,
'marital_status' => UserMaritalStatus::class,
'file_id' => 'int',
'province_id' => 'int',
'city_id' => 'int',
'status' => 'int',
'status' => UserStatus::class,
'deleted' => 'datetime'
];