fino a eventi e report prima del tipo di eventi
This commit is contained in:
+25
-3
@@ -127,7 +127,15 @@ class Evento extends Model
|
||||
|
||||
public function getOccorrenzeMensiliList(): array
|
||||
{
|
||||
$giorni = ['Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica'];
|
||||
$giorni = [
|
||||
0 => 'Domenica',
|
||||
1 => 'Lunedì',
|
||||
2 => 'Martedì',
|
||||
3 => 'Mercoledì',
|
||||
4 => 'Giovedì',
|
||||
5 => 'Venerdì',
|
||||
6 => 'Sabato',
|
||||
];
|
||||
$list = [];
|
||||
for ($occ = 1; $occ <= 4; $occ++) {
|
||||
foreach ($giorni as $idx => $giorno) {
|
||||
@@ -153,7 +161,15 @@ class Evento extends Model
|
||||
$occorrenza = (int) $parts[0];
|
||||
$giorno = (int) $parts[1];
|
||||
|
||||
$giorni = ['Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica'];
|
||||
$giorni = [
|
||||
0 => 'Domenica',
|
||||
1 => 'Lunedì',
|
||||
2 => 'Martedì',
|
||||
3 => 'Mercoledì',
|
||||
4 => 'Giovedì',
|
||||
5 => 'Venerdì',
|
||||
6 => 'Sabato',
|
||||
];
|
||||
|
||||
return $occorrenza . '° ' . ($giorni[$giorno] ?? '-');
|
||||
}
|
||||
@@ -199,7 +215,13 @@ class Evento extends Model
|
||||
}
|
||||
|
||||
$mesiLabels = $this->getMesiList();
|
||||
return $mesiLabels[$this->mese_annuale]['label'] ?? '-';
|
||||
$label = $mesiLabels[$this->mese_annuale]['label'] ?? '-';
|
||||
|
||||
if ($this->giorno_mese) {
|
||||
$label .= ' (giorno ' . $this->giorno_mese . ')';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function getPeriodicitaLabelAttribute(): string
|
||||
|
||||
+36
-12
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user