| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace App\Http\Livewire;
- use Livewire\Component;
- class CourseList extends Component
- {
- public $records = array();
- public $courses = array();
- public $counrsId = 0;
- public $months = array('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic');
- public function mount()
- {
- $this->courses = \App\Models\Course::orderBy('name')->get();
- if (sizeof($this->courses) > 0)
- $this->courseId = $this->courses[0]->id;
- }
- public function render()
- {
- // Carico tutti i corsi associati
- $member_course = \App\Models\MemberCourse::where('course_id', $this->courseId)->with('member')->get();
- $this->records = array();
- foreach($member_course as $x)
- {
- $this->records[] = array(
- $x->member_id . "§" . $x->member->first_name . " " . $x->member->last_name,
- $this->getColor($x->months, 1),
- $this->getColor($x->months, 2),
- $this->getColor($x->months, 3),
- $this->getColor($x->months, 4),
- $this->getColor($x->months, 5),
- $this->getColor($x->months, 6),
- $this->getColor($x->months, 7),
- $this->getColor($x->months, 8),
- $this->getColor($x->months, 9),
- $this->getColor($x->months, 10),
- $this->getColor($x->months, 11),
- $this->getColor($x->months, 12)
- );
- }
- return view('livewire.course_list');
- }
- public function getColor($months, $m)
- {
- $class = "grey";
- foreach(json_decode($months) as $mm)
- {
- if ($mm->m == $m)
- {
- if ($mm->status == "")
- {
- $class = "orange";
- }
- if ($mm->status == "1")
- {
- $class = "green";
- }
- if ($mm->status == "2")
- {
- $class = "yellow";
- }
- }
- }
- return $class;
- }
- }
|