| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App\Http\Livewire;
- use Livewire\Component;
- class CourseMember extends Component
- {
- public $records = array();
- public $courses = [];
- public $course_durations = [];
- public $course_types = [];
- public $course_levels = [];
- public $filterCourse = "";
- public $filterLevel = "";
- public $filterType = "";
- public $filterDuration = "";
- public $filterDays = "";
- public $filterHours = "";
- public $filterSubscription = "";
- public function mount()
- {
- $this->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 = "";
- }
- }
|