Files
kreios/backoffice/app/Models/Cliente.php
T

31 lines
668 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Cliente extends Model
{
protected $table = 'clienti';
protected $fillable = [
'nome', 'cognome', 'ragione_sociale', 'email', 'telefono',
'indirizzo', 'cap', 'citta', 'provincia', 'note',
];
public function preventivi(): HasMany
{
return $this->hasMany(Preventivo::class);
}
public function getNominativoAttribute(): string
{
if ($this->ragione_sociale) {
return $this->ragione_sociale;
}
return trim("{$this->nome} {$this->cognome}");
}
}