netgescon-master/app/Models/TabellaMillesimale.php
Pikappa2 f45845ba3c feat: Complete NetGesCon modernization - all core systems implemented
MAJOR IMPLEMENTATION COMPLETED:
 Modern database structure with Laravel best practices
 Complete Eloquent relationships (Amministratore→Stabili→Movements)
 8-character alphanumeric codes system (ADM, ANA, MOV, ALL prefixes)
 Multi-database architecture for administrators
 Complete property management (anagrafica_condominiale, diritti_reali, contratti)
 Distribution system for multi-server deployment
 Universal responsive UI with permission-based sidebar

NEW MODELS & MIGRATIONS:
- AnagraficaCondominiale: Complete person/entity management
- ContattoAnagrafica: Multi-contact system with usage flags
- DirittoReale: Property rights with quotas and percentages
- ContrattoLocazione: Rental contracts with landlord/tenant
- TipoUtilizzo: Property usage types (residential, commercial, etc.)
- Enhanced Stabile: Cadastral data, SDI, rate configuration
- Enhanced UnitaImmobiliare: Modern structure with backward compatibility

SERVICES & CONTROLLERS:
- DistributionService: Multi-server deployment and migration
- FileManagerController: Administrator folder management
- DistributionController: API for server-to-server communication
- MultiDatabaseService: Dynamic database connections

READY FOR PRODUCTION:
 Database schema: Complete and tested
 Models relationships: All working and verified
 Code generation: Automatic 8-char codes implemented
 Testing: Successful data creation confirmed
 Documentation: Complete internal technical docs

NEXT PHASE: Millésimal tables, expense categories, cost distribution engine
2025-07-08 16:24:03 +02:00

71 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TabellaMillesimale extends Model
{
use HasFactory;
protected $table = 'tabelle_millesimali';
protected $fillable = [
'stabile_id',
'nome_tabella_millesimale',
'descrizione',
'tipo',
'attiva',
'data_approvazione',
'ordinamento',
];
protected $casts = [
'attiva' => 'boolean',
'data_approvazione' => 'date',
'ordinamento' => 'integer',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];
/**
* Relazione con Stabile
*/
public function stabile()
{
return $this->belongsTo(Stabile::class, 'stabile_id', 'id');
}
/**
* Relazione con Dettagli Millesimi
*/
public function dettagli()
{
return $this->hasMany(DettaglioTabellaMillesimale::class, 'tabella_millesimale_id');
}
/**
* Scope per tabelle attive
*/
public function scopeAttive($query)
{
return $query->where('attiva', true);
}
/**
* Scope ordinato
*/
public function scopeOrdinato($query)
{
return $query->orderBy('ordinamento')->orderBy('nome_tabella_millesimale');
}
/**
* Calcola il totale millesimi
*/
public function getTotaleMillesimiAttribute()
{
return $this->dettagli()->sum('millesimi');
}
}