'boolean' ]; /** * Codice completo del conto */ public function getCodiceCompletoAttribute(): string { $parts = [$this->mastro, $this->conto, $this->sottoconto]; if (!empty($this->quarto_livello)) { $parts[] = $this->quarto_livello; } return implode('.', $parts); } /** * Codice mastro-conto */ public function getCodiceMastroContoAttribute(): string { return $this->mastro . '.' . $this->conto; } /** * Codice a 4 livelli (se presente quarto_livello) */ public function getCodiceQuattroLivelliAttribute(): string { $q = trim((string)($this->quarto_livello ?? '')); return $this->mastro . '.' . $this->conto . '.' . $this->sottoconto . ($q !== '' ? ('.' . $q) : ''); } /** * Scope per mastro */ public function scopeByMastro($query, $mastro) { return $query->where('mastro', $mastro); } /** * Scope per tipo */ public function scopeByTipo($query, $tipo) { return $query->where('tipo', $tipo); } /** * Scope attivi */ public function scopeAttivi($query) { return $query->where('attivo', true); } }