Car-Repairs-Shop/app/Models/Customer.php
sackey 5403c3591d
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
feat: Enhance job card workflow with diagnosis actions and technician assignment modal
- Added buttons for assigning diagnosis and starting diagnosis based on job card status in the job card view.
- Implemented a modal for assigning technicians for diagnosis, including form validation and technician selection.
- Updated routes to include a test route for job cards.
- Created a new Blade view for testing inspection inputs.
- Developed comprehensive feature tests for the estimate module, including creation, viewing, editing, and validation of estimates.
- Added tests for estimate model relationships and statistics calculations.
- Introduced a basic feature test for job cards index.
2025-08-15 08:37:45 +00:00

73 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;
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 getNameAttribute(): string
{
return $this->getFullNameAttribute();
}
public function getFormattedAddressAttribute(): string
{
return "{$this->address}, {$this->city}, {$this->state} {$this->zip_code}";
}
}