Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
40 lines
884 B
PHP
40 lines
884 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[Fillable([
|
|
'organization_id', 'location_id', 'first_name', 'last_name',
|
|
'title', 'email', 'phone', 'mobile', 'is_important', 'notes',
|
|
])]
|
|
class Contact extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_important' => 'boolean',
|
|
];
|
|
}
|
|
|
|
protected function fullName(): Attribute
|
|
{
|
|
return Attribute::get(fn () => trim("{$this->first_name} {$this->last_name}"));
|
|
}
|
|
|
|
public function organization()
|
|
{
|
|
return $this->belongsTo(Organization::class);
|
|
}
|
|
|
|
public function location()
|
|
{
|
|
return $this->belongsTo(Location::class);
|
|
}
|
|
}
|