57 lines
1.2 KiB
PHP
57 lines
1.2 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class FornitoreDipendente extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'fornitore_dipendenti';
|
|
|
|
protected $fillable = [
|
|
'fornitore_id',
|
|
'user_id',
|
|
'nome',
|
|
'cognome',
|
|
'email',
|
|
'telefono',
|
|
'attivo',
|
|
'ultimo_accesso_at',
|
|
'note',
|
|
'created_by_user_id',
|
|
'updated_by_user_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'attivo' => 'boolean',
|
|
'ultimo_accesso_at' => 'datetime',
|
|
];
|
|
|
|
public function fornitore()
|
|
{
|
|
return $this->belongsTo(Fornitore::class, 'fornitore_id');
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function creatoDaUser()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by_user_id');
|
|
}
|
|
|
|
public function aggiornatoDaUser()
|
|
{
|
|
return $this->belongsTo(User::class, 'updated_by_user_id');
|
|
}
|
|
|
|
public function getNomeCompletoAttribute(): string
|
|
{
|
|
return trim((string) ($this->nome . ' ' . ($this->cognome ?? '')));
|
|
}
|
|
}
|