ferrari 3 mesi fa
parent
commit
8cc8e28331
1 ha cambiato i file con 10 aggiunte e 7 eliminazioni
  1. 10 7
      app/Http/Livewire/Presence.php

+ 10 - 7
app/Http/Livewire/Presence.php

@@ -85,13 +85,16 @@ class Presence extends Component
             $months = date("n", strtotime($this->calendar->from));
 
             // Elenco utenti iscritti al corso "padre"
-            $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")
-                ->where('when', 'like', '%"from":"' . $h . '"%')
-                ->whereNot('months', 'like', '%"m":' . $months . ',"status":2%')
-                ->whereDate('date_from', '<=', $this->calendar->from)                                 
-                ->whereDate('date_to', '>=', $this->calendar->from)      
-                ->whereIn('course_id', $courses)
-                ->pluck('member_id')->toArray();
+            // $members_courses = \App\Models\MemberCourse::where('when', 'like', "%" . $d . "%")
+            //     ->where('when', 'like', '%"from":"' . $h . '"%')
+            //     ->whereNot('months', 'like', '%"m":' . $months . ',"status":2%')
+            //     ->whereDate('date_from', '<=', $this->calendar->from)                                 
+            //     ->whereDate('date_to', '>=', $this->calendar->from)      
+            //     ->whereIn('course_id', $courses)
+            //     ->pluck('member_id')->toArray();
+
+            $members_courses = \App\Models\MemberCourse::whereRaw("JSON_CONTAINS(`when`, JSON_OBJECT('day', JSON_ARRAY(?), 'from', ?), '$')", [$d, $h])->where('months', 'like', '%"m":' . $months . ',%')->whereIn('course_id', $courses)->pluck('member_id')->toArray();
+
 
             if ($this->filter != '') {
                 $filter = $this->filter;