38 lines
699 B
PHP
38 lines
699 B
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',
|
|
];
|
|
|
|
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);
|
|
}
|
|
}
|