'boolean' ]; public function amministratore(): BelongsTo { return $this->belongsTo(Administrator::class); } public function comune(): BelongsTo { return $this->belongsTo(Comune::class); } public function fatture() { return $this->hasMany(FatturaFornitore::class, 'fornitore_id'); } public function scopeAttivi($query) { return $query->where('attivo', true); } public function scopeByTipo($query, $tipo) { return $query->where('tipo_fornitore', $tipo); } public function scopeByCategoria($query, $categoria) { return $query->where('categoria_servizio', 'like', "%{$categoria}%"); } public function scopeSearch($query, $search) { return $query->where(function ($q) use ($search) { $q->where('denominazione', 'like', "%{$search}%") ->orWhere('cognome', 'like', "%{$search}%") ->orWhere('nome', 'like', "%{$search}%") ->orWhere('codice_fiscale', 'like', "%{$search}%") ->orWhere('partita_iva', 'like', "%{$search}%"); }); } public function getNomeCompletoAttribute() { if ($this->denominazione) { return $this->denominazione; } return trim($this->cognome . ' ' . $this->nome); } }