File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -332,7 +332,10 @@ public function getDirezioneAttribute()
332332 */
333333 public function getPesoCalcolatoAttribute ()
334334 {
335- $ righe = $ this ->getRighe ()->load (['articolo ' ]);
335+ $ righe = $ this ->getRighe ();
336+ $ righe ->filter (fn ($ item ) => $ item ->isArticolo ())->each (function ($ item ) {
337+ $ item ->load (['articolo ' ]);
338+ });
336339
337340 $ peso_lordo = $ righe ->sum (fn ($ item ) => $ item ->isArticolo () ? $ item ->articolo ->peso_lordo * $ item ->qta : 0 );
338341
@@ -347,7 +350,10 @@ public function getPesoCalcolatoAttribute()
347350 public function getVolumeCalcolatoAttribute ()
348351 {
349352 // Eager loading per evitare N+1 queries
350- $ righe = $ this ->getRighe ()->load (['articolo ' ]);
353+ $ righe = $ this ->getRighe ();
354+ $ righe ->filter (fn ($ item ) => $ item ->isArticolo ())->each (function ($ item ) {
355+ $ item ->load (['articolo ' ]);
356+ });
351357
352358 $ volume = $ righe ->sum (fn ($ item ) => $ item ->isArticolo () ? $ item ->articolo ->volume * $ item ->qta : 0 );
353359
You can’t perform that action at this time.
0 commit comments