Roberto Santini 1 месяц назад
Родитель
Сommit
59999a9de2
1 измененных файлов: 11 добавлений и 0 удалений
  1. 11
    0
      app/Models/ContrattoServizioRiga.php

+ 11
- 0
app/Models/ContrattoServizioRiga.php Просмотреть файл

262
         };
262
         };
263
     }
263
     }
264
 
264
 
265
+    public function needsPeriodo(): bool
266
+    {
267
+        $um = $this->unita_misura ?: optional($this->prodotto)->unita_misura;
268
+
269
+        return filled($um) && ! in_array($um, ['mese', 'anno', 'forfait'], true);
270
+    }
271
+
265
     public function getPeriodoLabelAttribute(): string
272
     public function getPeriodoLabelAttribute(): string
266
     {
273
     {
274
+        if (! $this->needsPeriodo()) {
275
+            return '—';
276
+        }
277
+
267
         return Prodotto::PERIODI[$this->periodo] ?? ($this->periodo ?: '—');
278
         return Prodotto::PERIODI[$this->periodo] ?? ($this->periodo ?: '—');
268
     }
279
     }
269
 }
280
 }

Загрузка…
Отмена
Сохранить