ferrari пре 3 месеци
родитељ
комит
8012055593
1 измењених фајлова са 36 додато и 4 уклоњено
  1. 36 4
      app/Http/Livewire/RecordINOUT.php

+ 36 - 4
app/Http/Livewire/RecordINOUT.php

@@ -225,7 +225,7 @@ class RecordINOUT extends Component
                 //     ->get();
                 // //$records = $records->orderBy('date', 'DESC')->get();
 
-                $recordsQuery = \App\Models\Record::where('type', 'IN')
+                $recordsQuery = \App\Models\Record::where('records.type', 'IN')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                     ->where(function ($query) {
@@ -248,12 +248,28 @@ class RecordINOUT extends Component
                     $recordsQuery->where(function ($q) use ($months, $years) {
                         foreach ($months as $month) {
                             $year = $years[$month];
+                            // variante entrambi numeri stringhe
                             $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
+                            // variante month stringa e year int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
+                            // variante month int e year stringa
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
+                            // variante entrambi numeri int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
                         }
                     });
 
                 } else {
-                    $recordsQuery->whereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                    $recordsQuery->where(function ($q) use ($m, $y) {
+                        // variante entrambi numeri stringhe
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                        // variante month stringa e year int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
+                        // variante month int e year stringa
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
+                        // variante entrambi numeri int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
+                    });
                 }
                 $records = $recordsQuery->get();
 
@@ -289,7 +305,7 @@ class RecordINOUT extends Component
                 //     ->where('records_rows.when', 'like', '%"' . $f . '"%')->get();
                 //$records = $records->orderBy('date', 'DESC')->get();
 
-                $recordsQuery = \App\Models\Record::where('type', 'OUT')
+                $recordsQuery = \App\Models\Record::where('records.type', 'OUT')
                     ->join('records_rows', 'records.id', '=', 'records_rows.record_id')
                     ->whereNotIn('records_rows.causal_id', $this->excludeCausals)
                     ->where(function ($query) {
@@ -312,12 +328,28 @@ class RecordINOUT extends Component
                     $recordsQuery->where(function ($q) use ($months, $years) {
                         foreach ($months as $month) {
                             $year = $years[$month];
+                            // variante entrambi numeri stringhe
                             $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":\"{$year}\"}')");
+                            // variante month stringa e year int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$month}\",\"year\":{$year}}')");
+                            // variante month int e year stringa
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":\"{$year}\"}')");
+                            // variante entrambi numeri int
+                            $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$month},\"year\":{$year}}')");
                         }
                     });
 
                 } else {
-                    $recordsQuery->whereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                    $recordsQuery->where(function ($q) use ($m, $y) {
+                        // variante entrambi numeri stringhe
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":\"{$y}\"}')");
+                        // variante month stringa e year int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":\"{$m}\",\"year\":{$y}}')");
+                        // variante month int e year stringa
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":\"{$y}\"}')");
+                        // variante entrambi numeri int
+                        $q->orWhereRaw("JSON_CONTAINS(`records_rows`.`when`, '{\"month\":{$m},\"year\":{$y}}')");
+                    });
                 }
                 $records = $recordsQuery->get();