Car-Repairs-Shop/app/Models/Customer.php
sackey e3b2b220d2
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
Enhance UI and functionality across various components
- Increased icon sizes in service items, service orders, users, and technician management for better visibility.
- Added custom loading indicators with appropriate icons in search fields for vehicles, work orders, and technicians.
- Introduced invoice management routes for better organization and access control.
- Created a new test for the estimate PDF functionality to ensure proper rendering and data integrity.
2025-08-16 14:36:58 +00:00

74 lines
1.6 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;
use Illuminate\Notifications\Notifiable;
class Customer extends Model
{
/** @use HasFactory<\Database\Factories\CustomerFactory> */
use HasFactory, Notifiable;
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 getNameAttribute(): string
{
return $this->getFullNameAttribute();
}
public function getFormattedAddressAttribute(): string
{
return "{$this->address}, {$this->city}, {$this->state} {$this->zip_code}";
}
}