- Implemented dashboard view with vehicle stats, active services, recent activity, and upcoming appointments. - Created estimates view with filtering options and a list of service estimates. - Developed invoices view to manage service invoices and payment history with filtering. - Added vehicles view to display registered vehicles and their details. - Built work orders view to track the progress of vehicle services with filtering and detailed information.
71 lines
1.5 KiB
PHP
71 lines
1.5 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\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Vehicle extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\VehicleFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'customer_id',
|
|
'vin',
|
|
'make',
|
|
'model',
|
|
'year',
|
|
'color',
|
|
'license_plate',
|
|
'engine_type',
|
|
'transmission',
|
|
'mileage',
|
|
'notes',
|
|
'status',
|
|
'last_service_date',
|
|
'vehicle_image',
|
|
];
|
|
|
|
protected $casts = [
|
|
'last_service_date' => 'datetime',
|
|
];
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function serviceOrders(): HasMany
|
|
{
|
|
return $this->hasMany(ServiceOrder::class);
|
|
}
|
|
|
|
public function appointments(): HasMany
|
|
{
|
|
return $this->hasMany(Appointment::class);
|
|
}
|
|
|
|
public function jobCards(): HasMany
|
|
{
|
|
return $this->hasMany(JobCard::class);
|
|
}
|
|
|
|
public function inspections(): HasMany
|
|
{
|
|
return $this->hasMany(VehicleInspection::class);
|
|
}
|
|
|
|
public function getDisplayNameAttribute(): string
|
|
{
|
|
return "{$this->year} {$this->make} {$this->model}";
|
|
}
|
|
|
|
public function getVinDisplayAttribute(): string
|
|
{
|
|
return strtoupper(substr($this->vin, -8));
|
|
}
|
|
}
|