@@ -82,14 +82,25 @@ public static function build(Anagrafica $anagrafica, TipoSessione $tipo_sessione
8282 public function getOreTotaliAttribute ()
8383 {
8484 if (!isset ($ this ->info ['ore_totali ' ])) {
85- $ sessioni = $ this ->sessioni ()-> leftJoin ( ' in_tipiintervento ' , ' in_interventi_tecnici.idtipointervento ' , ' in_tipiintervento.id ' )-> where ( ' non_conteggiare ' , 0 ) ;
85+ $ sessioni = $ this ->sessioni ;
8686
8787 $ this ->info ['ore_totali ' ] = $ sessioni ->sum ('ore ' );
8888 }
8989
9090 return $ this ->info ['ore_totali ' ];
9191 }
9292
93+ public function getOreTotaliDaConteggiareAttribute ()
94+ {
95+ if (!isset ($ this ->info ['ore_totali_da_conteggiare ' ])) {
96+ $ sessioni = $ this ->sessioni ()->leftJoin ('in_tipiintervento ' , 'in_interventi_tecnici.idtipointervento ' , 'in_tipiintervento.id ' )->where ('non_conteggiare ' , 0 );
97+
98+ $ this ->info ['ore_totali_da_conteggiare ' ] = $ sessioni ->sum ('ore ' );
99+ }
100+
101+ return $ this ->info ['ore_totali_da_conteggiare ' ];
102+ }
103+
93104 public function getKmTotaliAttribute ()
94105 {
95106 if (!isset ($ this ->info ['km_totali ' ])) {
@@ -197,6 +208,7 @@ public function toArray()
197208
198209 $ result = array_merge ($ array , [
199210 'ore_totali ' => $ this ->ore_totali ,
211+ 'ore_totali_da_conteggiare ' => $ this ->ore_totali_da_conteggiare ,
200212 'km_totali ' => $ this ->km_totali ,
201213 ]);
202214
0 commit comments