Roberto Santini il y a 1 semaine
Parent
révision
17b1ec9bbf
1 fichiers modifiés avec 7 ajouts et 7 suppressions
  1. 7
    7
      app/Models/ContrattoServizio.php

+ 7
- 7
app/Models/ContrattoServizio.php Voir le fichier

286
             return $this->righe;
286
             return $this->righe;
287
         }
287
         }
288
 
288
 
289
-        $this->loadMissing('contrattoServizioRigas.prodotto');
289
+        $this->loadMissing('righe.prodotto');
290
 
290
 
291
-        return $this->contrattoServizioRigas;
291
+        return $this->righe;
292
     }
292
     }
293
 
293
 
294
     public function getPeriodoLabelAttribute(): string
294
     public function getPeriodoLabelAttribute(): string
306
         if (! $this->contratto_template_id) {
306
         if (! $this->contratto_template_id) {
307
             return 0;
307
             return 0;
308
         }
308
         }
309
-        if (! $force && $this->contrattoServizioTodos()->exists()) {
309
+        if (! $force && $this->todos()->exists()) {
310
             return 0;
310
             return 0;
311
         }
311
         }
312
         if ($force) {
312
         if ($force) {
313
-            $this->contrattoServizioTodos()->delete();
313
+            $this->todos()->delete();
314
         }
314
         }
315
 
315
 
316
         $template = ContrattoTemplate::with('contrattoTemplateTodos')->find($this->contratto_template_id);
316
         $template = ContrattoTemplate::with('contrattoTemplateTodos')->find($this->contratto_template_id);
357
         if (! $this->contratto_template_id) {
357
         if (! $this->contratto_template_id) {
358
             return 0;
358
             return 0;
359
         }
359
         }
360
-        if (! $force && $this->contrattoServizioRigas()->exists()) {
360
+        if (! $force && $this->righe()->exists()) {
361
             return 0;
361
             return 0;
362
         }
362
         }
363
         if ($force) {
363
         if ($force) {
364
-            $this->contrattoServizioRigas()->delete();
364
+            $this->righe()->delete();
365
         }
365
         }
366
 
366
 
367
         $template = ContrattoTemplate::with('contrattoTemplateRigas.prodotto')->find($this->contratto_template_id);
367
         $template = ContrattoTemplate::with('contrattoTemplateRigas.prodotto')->find($this->contratto_template_id);
370
         }
370
         }
371
 
371
 
372
         $count = 0;
372
         $count = 0;
373
-        foreach ($template->contrattoTemplateRigas as $riga) {
373
+        foreach ($template->righe as $riga) {
374
             ContrattoServizioRiga::create([
374
             ContrattoServizioRiga::create([
375
                 'contratto_servizio_id' => $this->id,
375
                 'contratto_servizio_id' => $this->id,
376
                 'prodotto_id' => $riga->prodotto_id,
376
                 'prodotto_id' => $riga->prodotto_id,

Chargement…
Annuler
Enregistrer