60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Booking extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'uuid',
|
|
'ride_id',
|
|
'offer_id',
|
|
'ride_recommendation_id',
|
|
'customer_name',
|
|
'customer_email',
|
|
'customer_phone',
|
|
'party_size',
|
|
'booking_for',
|
|
'status',
|
|
'amount',
|
|
'commission_amount',
|
|
'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'booking_for' => 'datetime',
|
|
'amount' => 'decimal:2',
|
|
'commission_amount' => 'decimal:2',
|
|
];
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (Booking $booking) {
|
|
if (blank($booking->uuid)) {
|
|
$booking->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function ride(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Ride::class);
|
|
}
|
|
|
|
public function offer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Offer::class);
|
|
}
|
|
|
|
public function recommendation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(RideRecommendation::class, 'ride_recommendation_id');
|
|
}
|
|
}
|