2026-08-08 21:43:15 +07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Modules\Booking\Models;
|
|
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Modules\Booking\Database\Factories\BookingFactory;
|
|
|
|
|
use Modules\Booking\Enums\BookingChannel;
|
|
|
|
|
use Modules\Booking\Enums\BookingStatus;
|
|
|
|
|
use Modules\Catalog\Models\DepartureTimeSlot;
|
2026-08-08 22:42:16 +07:00
|
|
|
use Modules\Payment\Models\Payment;
|
2026-08-08 21:43:15 +07:00
|
|
|
use Modules\Routing\Models\EvRoute;
|
|
|
|
|
|
|
|
|
|
class Booking extends Model
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<BookingFactory> */
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'booking_ref',
|
|
|
|
|
'user_id',
|
|
|
|
|
'openid',
|
|
|
|
|
'ev_route_id',
|
|
|
|
|
'departure_time_slot_id',
|
|
|
|
|
'travel_date',
|
|
|
|
|
'passenger_name',
|
|
|
|
|
'passenger_phone',
|
|
|
|
|
'pickup_address',
|
|
|
|
|
'pickup_lat',
|
|
|
|
|
'pickup_lng',
|
|
|
|
|
'dropoff_address',
|
|
|
|
|
'dropoff_lat',
|
|
|
|
|
'dropoff_lng',
|
|
|
|
|
'price',
|
|
|
|
|
'status',
|
|
|
|
|
'is_round_trip',
|
|
|
|
|
'return_travel_date',
|
|
|
|
|
'created_by_channel',
|
|
|
|
|
'driver_name',
|
|
|
|
|
'driver_phone',
|
|
|
|
|
'car_plate_number',
|
|
|
|
|
'car_model',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'travel_date' => 'date',
|
|
|
|
|
'pickup_lat' => 'decimal:7',
|
|
|
|
|
'pickup_lng' => 'decimal:7',
|
|
|
|
|
'dropoff_lat' => 'decimal:7',
|
|
|
|
|
'dropoff_lng' => 'decimal:7',
|
|
|
|
|
'price' => 'decimal:2',
|
|
|
|
|
'status' => BookingStatus::class,
|
|
|
|
|
'is_round_trip' => 'boolean',
|
|
|
|
|
'return_travel_date' => 'date',
|
|
|
|
|
'created_by_channel' => BookingChannel::class,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function route(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(EvRoute::class, 'ev_route_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function timeSlot(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(DepartureTimeSlot::class, 'departure_time_slot_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function vehicleOptions(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(BookingVehicleOption::class);
|
|
|
|
|
}
|
2026-08-08 22:42:16 +07:00
|
|
|
|
|
|
|
|
public function payments(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Payment::class);
|
|
|
|
|
}
|
2026-08-08 21:43:15 +07:00
|
|
|
}
|