54 lines
1.0 KiB
PHP
54 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Owner extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'paternal',
|
|
'maternal',
|
|
'rfc',
|
|
'curp',
|
|
'address',
|
|
'tipopers',
|
|
'pasaporte',
|
|
'licencia',
|
|
'ent_fed',
|
|
'munic',
|
|
'callep',
|
|
'num_ext',
|
|
'num_int',
|
|
'colonia',
|
|
'cp',
|
|
'telefono',
|
|
];
|
|
|
|
protected $appends = [
|
|
'full_name',
|
|
];
|
|
|
|
protected function fullName(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn() => trim("{$this->name} {$this->paternal} {$this->maternal}")
|
|
);
|
|
}
|
|
|
|
public function vehicles()
|
|
{
|
|
return $this->hasMany(Vehicle::class);
|
|
}
|
|
|
|
public function municipality()
|
|
{
|
|
return $this->belongsTo(Municipality::class, 'munic', 'code');
|
|
}
|
|
}
|