fino a eventi e report prima del tipo di eventi

This commit is contained in:
2026-05-26 11:47:36 +02:00
parent 0bed099d05
commit f088dba4bf
47 changed files with 1733 additions and 6899 deletions
+36 -12
View File
@@ -5,6 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Gruppo extends Model
@@ -48,24 +49,47 @@ class Gruppo extends Model
->withTimestamps();
}
public function avatar(): HasOne
{
return $this->hasOne(Documento::class, 'visibilita_target_id')
->where('tipologia', 'avatar')
->where('visibilita_target_type', self::class);
}
public function getAvatarUrlAttribute(): ?string
{
if ($this->avatar && $this->avatar->file_path) {
return url('/gruppi/' . $this->id . '/avatar-file');
}
return null;
}
public function getResponsabili()
{
if (empty($this->responsabile_ids)) {
return collect();
}
$ids = is_array($this->responsabile_ids)
? $this->responsabile_ids
: json_decode($this->responsabile_ids, true);
if (empty($ids)) {
return collect();
}
return Individuo::whereIn('id', $ids)->get();
}
public function getResponsabiliIds(): array
{
if (empty($this->responsabile_ids)) {
return [];
}
if (is_array($this->responsabile_ids)) {
return $this->responsabile_ids;
}
return json_decode($this->responsabile_ids, true) ?? [];
}
public function getResponsabili(): \Illuminate\Database\Eloquent\Collection
{
$ids = $this->getResponsabiliIds();
if (empty($ids)) {
return new \Illuminate\Database\Eloquent\Collection();
}
return Individuo::whereIn('id', $ids)->get();
return is_array($this->responsabile_ids)
? $this->responsabile_ids
: json_decode($this->responsabile_ids, true) ?? [];
}
public function eventi(): BelongsToMany