Car-Repairs-Shop/app/Models/VehicleInspection.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

97 lines
2.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class VehicleInspection extends Model
{
/** @use HasFactory<\Database\Factories\VehicleInspectionFactory> */
use HasFactory;
protected $fillable = [
'job_card_id',
'service_order_id',
'vehicle_id',
'inspector_id',
'inspection_type', // 'incoming', 'outgoing'
'current_mileage',
'fuel_level',
'inspection_checklist',
'photos',
'videos',
'overall_condition',
'recommendations',
'discrepancies_found',
'damage_notes',
'cleanliness_rating',
'inspection_date',
'signature_inspector',
'signature_customer',
'notes',
'additional_comments',
'follow_up_required',
'quality_rating',
'damage_diagram_data',
];
protected $casts = [
'inspection_checklist' => 'array',
'photos' => 'array',
'videos' => 'array',
'recommendations' => 'array',
'discrepancies_found' => 'array',
'damage_diagram_data' => 'array',
'inspection_date' => 'datetime',
'follow_up_required' => 'boolean',
];
public function jobCard(): BelongsTo
{
return $this->belongsTo(JobCard::class);
}
public function serviceOrder(): BelongsTo
{
return $this->belongsTo(ServiceOrder::class);
}
public function vehicle(): BelongsTo
{
return $this->belongsTo(Vehicle::class);
}
public function inspector(): BelongsTo
{
return $this->belongsTo(User::class, 'inspector_id');
}
public function scopeIncoming($query)
{
return $query->where('inspection_type', 'incoming');
}
public function scopeOutgoing($query)
{
return $query->where('inspection_type', 'outgoing');
}
public function compareWithOtherInspection(VehicleInspection $otherInspection): array
{
$differences = [];
if ($this->overall_condition !== $otherInspection->overall_condition) {
$differences['overall_condition'] = [
'before' => $otherInspection->overall_condition,
'after' => $this->overall_condition,
];
}
// Add more comparison logic as needed
return $differences;
}
}