- 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.
68 lines
1.5 KiB
PHP
68 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\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Customer extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\CustomerFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'first_name',
|
|
'last_name',
|
|
'email',
|
|
'phone',
|
|
'secondary_phone',
|
|
'address',
|
|
'city',
|
|
'state',
|
|
'zip_code',
|
|
'notes',
|
|
'status',
|
|
'last_service_date',
|
|
];
|
|
|
|
protected $casts = [
|
|
'last_service_date' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Get the user account associated with this customer
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function vehicles(): HasMany
|
|
{
|
|
return $this->hasMany(Vehicle::class);
|
|
}
|
|
|
|
public function serviceOrders(): HasMany
|
|
{
|
|
return $this->hasMany(ServiceOrder::class);
|
|
}
|
|
|
|
public function appointments(): HasMany
|
|
{
|
|
return $this->hasMany(Appointment::class);
|
|
}
|
|
|
|
public function getFullNameAttribute(): string
|
|
{
|
|
return "{$this->first_name} {$this->last_name}";
|
|
}
|
|
|
|
public function getFormattedAddressAttribute(): string
|
|
{
|
|
return "{$this->address}, {$this->city}, {$this->state} {$this->zip_code}";
|
|
}
|
|
}
|