71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Scadenza extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'scadenze';
|
|
|
|
protected $fillable = [
|
|
'legacy_id',
|
|
'stabile_id',
|
|
'stabile_contratto_id',
|
|
'codice_stabile_legacy',
|
|
'descrizione_sintetica',
|
|
'data_scadenza',
|
|
'ora_scadenza',
|
|
'natura',
|
|
'natura_label',
|
|
'gestione_tipo',
|
|
'num_assemblea',
|
|
'numero_straordinaria',
|
|
'anno',
|
|
'rata',
|
|
'fatto',
|
|
'tipo_riga',
|
|
'rif_f24',
|
|
'importo_f24',
|
|
'richiede_pop_up',
|
|
'giorni_anticipo',
|
|
'popup_dal',
|
|
'calendar_event_id',
|
|
'calendar_synced_at',
|
|
'legacy_payload',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data_scadenza' => 'date',
|
|
'popup_dal' => 'date',
|
|
'richiede_pop_up' => 'boolean',
|
|
'importo_f24' => 'decimal:2',
|
|
'calendar_synced_at' => 'datetime',
|
|
'legacy_payload' => 'array',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
public function stabile()
|
|
{
|
|
return $this->belongsTo(Stabile::class, 'stabile_id');
|
|
}
|
|
|
|
public function stabileContratto()
|
|
{
|
|
return $this->belongsTo(StabileContratto::class, 'stabile_contratto_id');
|
|
}
|
|
|
|
public function getTitoloCalendarioAttribute(): string
|
|
{
|
|
$parts = array_filter([
|
|
$this->natura_label ?: $this->natura,
|
|
trim((string) ($this->descrizione_sintetica ?? '')),
|
|
]);
|
|
|
|
return implode(' - ', $parts) ?: ('Scadenza #' . (int) $this->id);
|
|
}
|
|
}
|