kevin 284d228dc5 feat(vehicle): add vehicle+convoy feature with API, models, repos, UI
Adds model, repo, controller, and request classes for Vehicle and Convoy.
Registers routes for vehicles and convoys, updates client store.
Adds front‑end files to list, add, edit vehicles.
Cleans up console logging from client store.
2026-04-15 17:27:40 +03:00

81 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\HasMany;
class Deceased extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'deceased';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'last_name',
'first_name',
'birth_date',
'death_date',
'place_of_death',
'notes'
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'birth_date' => 'date',
'death_date' => 'date',
];
/**
* Get the documents associated with the deceased.
*/
public function documents(): HasMany
{
return $this->hasMany(DeceasedDocument::class);
}
/**
* Get the interventions associated with the deceased.
*/
public function interventions(): HasMany
{
return $this->hasMany(Intervention::class);
}
public function convoys(): HasMany
{
return $this->hasMany(Convoy::class);
}
/**
* Get the file attachments for the deceased (polymorphic).
*/
public function fileAttachments()
{
return $this->morphMany(FileAttachment::class, 'attachable')->orderBy('sort_order');
}
/**
* Get the files attached to this deceased.
*/
public function attachedFiles()
{
return $this->fileAttachments()->with('file');
}
}