// SYSTEM PANEL //
[ROOT]
/
mnt
/
pleskStorage
/
vhosts
/
kodsolutions.net
/
subdomains
/
go-rent.kodsolutions.net
/
app
/
Models
/
Car
[ PARENT ]
EDIT :: CarRental.php
<?php namespace App\Models\Car; use App\Models\Model; use App\Models\User; use Illuminate\Database\Eloquent\Factories\HasFactory; class CarRental extends Model { use HasFactory; /** * The table associated with the model. * * @var string */ protected $table = 'car_rentals'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'car_id', 'user_id', 'start_date', 'end_date', 'total_price', 'status', 'booking_number', 'customer_name', 'customer_phone', 'notes' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'start_date' => 'date', 'end_date' => 'date', 'total_price' => 'decimal:2', ]; /** * Get the car that owns the rental. */ public function car() { return $this->belongsTo(Car::class); } /** * Get the user that owns the rental. */ public function user() { return $this->belongsTo(User::class); } /** * Get the rental duration in days. */ public function getDurationAttribute() { return $this->start_date->diffInDays($this->end_date) + 1; } /** * Get the status badge HTML. */ public function getStatusBadgeAttribute() { $badgeClasses = [ 'pending' => 'bg-warning', 'confirmed' => 'bg-success', 'cancelled' => 'bg-danger', ]; $class = $badgeClasses[$this->status] ?? 'bg-secondary'; return '<span class="badge ' . $class . '">' . ucfirst($this->status) . '</span>'; } }
SAVE
CANCEL