course_types = \App\Models\CourseType::select('*')->where('enabled', true)->get(); $this->course_durations = \App\Models\CourseDuration::select('*')->where('enabled', true)->get(); $this->course_levels = \App\Models\CourseLevel::select('*')->where('enabled', true)->get(); $this->courses = \App\Models\Course::select('*')->orderBy('name', 'ASC')->get(); } public function render() { // Carico tutti i corsi associati $datas = \App\Models\MemberCourse::with('member'); if ($this->filterCourse != "") $datas = $datas->where('course_id', $this->filterCourse); if ($this->filterLevel != "") { $course_ids = \App\Models\Course::where('course_level_id', $this->filterLevel)->pluck('id'); $datas = $datas->whereIn('course_id', $course_ids); } if ($this->filterType != "") { $course_ids = \App\Models\Course::where('course_type_id', $this->filterType)->pluck('id'); $datas = $datas->whereIn('course_id', $course_ids); } if ($this->filterDuration != "") { $course_ids = \App\Models\Course::where('course_duration_id', $this->filterDuration)->pluck('id'); $datas = $datas->whereIn('course_id', $course_ids); } if ($this->filterDays != "") { $course_ids = \App\Models\Membercourse::where('when', 'like', "%" . $this->filterDays . "%")->pluck('course_id'); $datas = $datas->whereIn('course_id', $course_ids); } if ($this->filterHours != "") { $course_ids = \App\Models\Membercourse::where('when', 'like', "%" . $this->filterHours . "%")->pluck('course_id'); $datas = $datas->whereIn('course_id', $course_ids); } if ($this->filterSubscription != "") { $course_ids = \App\Models\MemberCourse::where('subscribed', $this->filterSubscription == 1 ? true : false)->pluck('id'); $datas = $datas->whereIn('course_id', $course_ids); } $this->records = $datas->get(); $this->emit('load-data-table'); return view('livewire.course_member'); } public function search() { } public function disableSearch() { $this->filterCourse = ""; $this->filterLevel = ""; $this->filterType = ""; $this->filterDuration = ""; $this->filterDays = ""; $this->filterHours = ""; $this->filterSubscription = ""; } }