@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $events = Event::with('course') |
26 | 26 | ->where('start', '>', Carbon::now()->subDays(30))->where('end', '<', Carbon::now()->addDays(30))->orderBy('id', 'desc') // TODO optimize this. |
27 | 27 | ->get() |
28 | - ->map(fn ($event) => [ |
|
28 | + ->map(fn($event) => [ |
|
29 | 29 | 'title' => $event->name ?? '', |
30 | 30 | 'resourceId' => $event->teacher_id, |
31 | 31 | 'start' => $event->start, |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | |
38 | 38 | $teachers = Teacher::all()->toArray(); |
39 | 39 | |
40 | - $teachers = array_map(fn ($teacher) => [ |
|
40 | + $teachers = array_map(fn($teacher) => [ |
|
41 | 41 | 'id' => $teacher['id'], |
42 | 42 | 'title' => $teacher['name'] ?? '', |
43 | 43 | ], $teachers); |
44 | 44 | |
45 | 45 | array_push($teachers, ['id' => 'tbd', 'title' => 'Unassigned']); |
46 | 46 | |
47 | - $unassigned_events = Event::unassigned()->get()->map(fn ($event) => [ |
|
47 | + $unassigned_events = Event::unassigned()->get()->map(fn($event) => [ |
|
48 | 48 | 'title' => $event->name ?? '', |
49 | 49 | 'resourceId' => 'tbd', |
50 | 50 | 'start' => $event->start, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'borderColor' => $event->color, |
55 | 55 | ]); |
56 | 56 | |
57 | - $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn ($event) => [ |
|
57 | + $leaves = Leave::orderBy('date', 'desc')->limit(10000)->get()->map(fn($event) => [ |
|
58 | 58 | 'title' => $event->leaveType->name ?? 'ABS', // todo fix |
59 | 59 | 'resourceId' => $event['teacher_id'], |
60 | 60 | 'start' => $event['date'], |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | abort(403); |
81 | 81 | } |
82 | 82 | |
83 | - $events = $teacher->events->map(fn ($event) => [ |
|
83 | + $events = $teacher->events->map(fn($event) => [ |
|
84 | 84 | 'title' => $event['name'], |
85 | 85 | 'start' => $event['start'], |
86 | 86 | 'end' => $event['end'], |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | 'borderColor' => $event['color'], |
89 | 89 | ]); |
90 | 90 | |
91 | - $leaves = $teacher->leaves->map(fn ($event) => [ |
|
92 | - 'title' => $event->leaveType->name ?? 'vacances', // todo fix |
|
91 | + $leaves = $teacher->leaves->map(fn($event) => [ |
|
92 | + 'title' => $event->leaveType->name ?? 'vacances', // todo fix |
|
93 | 93 | 'start' => $event['date'], |
94 | 94 | 'allDay' => true, |
95 | 95 | ]); |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | ->where('end', '<', Carbon::now()->addDays(90)) |
26 | 26 | ->orderBy('id', 'desc') |
27 | 27 | ->get() |
28 | - ->map(fn ($event) => [ |
|
28 | + ->map(fn($event) => [ |
|
29 | 29 | 'title' => $event->name, |
30 | 30 | 'resourceId' => $event->room_id, |
31 | 31 | 'start' => $event->start, |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | $rooms = Room::all()->toArray(); |
39 | 39 | |
40 | - $rooms = array_map(fn ($room) => [ |
|
40 | + $rooms = array_map(fn($room) => [ |
|
41 | 41 | 'id' => $room['id'], |
42 | 42 | 'title' => $room['name'], |
43 | 43 | ], $rooms); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $unassigned_events = Event::with('course') |
48 | 48 | ->whereNull('room_id') |
49 | 49 | ->get() |
50 | - ->map(fn ($event) => [ |
|
50 | + ->map(fn($event) => [ |
|
51 | 51 | 'title' => $event->name, |
52 | 52 | 'resourceId' => 'tbd', |
53 | 53 | 'start' => $event->start, |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | public function show(Room $room) |
71 | 71 | { |
72 | 72 | $events = $room->events->toArray(); |
73 | - $events = array_map(fn ($event) => [ |
|
73 | + $events = array_map(fn($event) => [ |
|
74 | 74 | 'title' => $event['name'], |
75 | 75 | 'start' => $event['start'], |
76 | 76 | 'end' => $event['end'], |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'label' => trans('backpack::permissionmanager.email'), |
49 | 49 | 'type' => 'email', |
50 | 50 | ], |
51 | - [ // n-n relationship (with pivot table) |
|
51 | + [// n-n relationship (with pivot table) |
|
52 | 52 | 'label' => trans('backpack::permissionmanager.roles'), |
53 | 53 | 'type' => 'select_multiple', |
54 | 54 | 'name' => 'roles', |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | 'label' => trans('backpack::permissionmanager.role'), |
68 | 68 | ], |
69 | 69 | config('permission.models.role')::all()->pluck(['name', 'id'])->toArray(), |
70 | - function ($value) { |
|
70 | + function($value) { |
|
71 | 71 | // if the filter is active |
72 | - $this->crud->addClause('whereHas', 'roles', function ($query) use ($value) { |
|
72 | + $this->crud->addClause('whereHas', 'roles', function($query) use ($value) { |
|
73 | 73 | $query->where('role_id', '=', $value); |
74 | 74 | }); |
75 | 75 | } |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | protected function addFields() |
121 | 121 | { |
122 | 122 | $this->crud->addFields([ |
123 | - [ // Select2 |
|
123 | + [// Select2 |
|
124 | 124 | 'label' => trans('firstname'), |
125 | 125 | 'type' => 'text', |
126 | 126 | 'name' => 'firstname', |
127 | 127 | ], |
128 | - [ // Select2 |
|
128 | + [// Select2 |
|
129 | 129 | 'label' => trans('lastname'), |
130 | 130 | 'type' => 'text', |
131 | 131 | 'name' => 'lastname', |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | protected function setupListOperation() |
32 | 32 | { |
33 | 33 | CRUD::setColumns([ |
34 | - [ // skill type |
|
34 | + [// skill type |
|
35 | 35 | 'label' => 'Type', |
36 | 36 | 'type' => 'select', |
37 | 37 | 'name' => 'skill_type', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | 'type' => 'text', |
45 | 45 | 'name' => 'name', |
46 | 46 | ], |
47 | - [ // skill level |
|
47 | + [// skill level |
|
48 | 48 | 'label' => 'Level', |
49 | 49 | 'type' => 'select', |
50 | 50 | 'name' => 'level', |
@@ -56,19 +56,19 @@ discard block |
||
56 | 56 | |
57 | 57 | CRUD::enableExportButtons(); |
58 | 58 | |
59 | - CRUD::addFilter([ // select2 filter |
|
59 | + CRUD::addFilter([// select2 filter |
|
60 | 60 | 'name' => 'level_id', |
61 | 61 | 'type' => 'select2', |
62 | 62 | 'label'=> 'Level', |
63 | - ], fn () => Level::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
63 | + ], fn() => Level::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
64 | 64 | CRUD::addClause('where', 'level_id', $value); |
65 | 65 | }); |
66 | 66 | |
67 | - CRUD::addFilter([ // select2 filter |
|
67 | + CRUD::addFilter([// select2 filter |
|
68 | 68 | 'name' => 'skill_type_id', |
69 | 69 | 'type' => 'select2', |
70 | 70 | 'label'=> 'Type', |
71 | - ], fn () => SkillType::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active |
|
71 | + ], fn() => SkillType::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active |
|
72 | 72 | CRUD::addClause('where', 'skill_type_id', $value); |
73 | 73 | }); |
74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | CRUD::setValidation(StoreRequest::class); |
79 | 79 | CRUD::addFields([ |
80 | - [ // skill type |
|
80 | + [// skill type |
|
81 | 81 | 'label' => 'Type', |
82 | 82 | 'type' => 'select', |
83 | 83 | 'name' => 'skill_type_id', // the db column for the foreign key |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'type' => 'text', |
91 | 91 | 'name' => 'name', |
92 | 92 | ], |
93 | - [ // skill level |
|
93 | + [// skill level |
|
94 | 94 | 'label' => 'Level', |
95 | 95 | 'type' => 'select', |
96 | 96 | 'name' => 'level_id', // the db column for the foreign key |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'type' => 'relationship', |
104 | 104 | 'name' => 'skill_type', // the method on your model that defines the relationship |
105 | 105 | 'ajax' => true, |
106 | - 'inline_create' => [ // specify the entity in singular |
|
106 | + 'inline_create' => [// specify the entity in singular |
|
107 | 107 | 'entity' => 'skilltype', // the entity in singular |
108 | 108 | // OPTIONALS |
109 | 109 | 'force_select' => true, // should the inline-created entry be immediately selected? |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | 'attribute' => 'lastname', |
47 | 47 | 'model' => \App\Models\User::class, |
48 | 48 | 'orderable' => true, |
49 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
49 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'students.id') |
|
50 | 50 | ->orderBy('users.lastname', $columnDirection)->select('students.*'), |
51 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
52 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
51 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
52 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
53 | 53 | $q->where('lastname', 'like', '%'.$searchTerm.'%'); |
54 | 54 | }); |
55 | 55 | }, |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | 'attribute' => 'firstname', |
65 | 65 | 'model' => \App\Models\User::class, |
66 | 66 | 'orderable' => true, |
67 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id') |
|
67 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id') |
|
68 | 68 | ->orderBy('users.firstname', $columnDirection)->select('teachers.*'), |
69 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
70 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
69 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
70 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
71 | 71 | $q->where('firstname', 'like', '%'.$searchTerm.'%'); |
72 | 72 | }); |
73 | 73 | }, |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | 'attribute' => 'email', |
82 | 82 | 'model' => \App\Models\User::class, |
83 | 83 | 'orderable' => true, |
84 | - 'orderLogic' => fn ($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id') |
|
84 | + 'orderLogic' => fn($query, $column, $columnDirection) => $query->leftJoin('users', 'users.id', '=', 'teachers.id') |
|
85 | 85 | ->orderBy('users.email', $columnDirection)->select('teachers.*'), |
86 | - 'searchLogic' => function ($query, $column, $searchTerm) { |
|
87 | - $query->orWhereHas('user', function ($q) use ($searchTerm) { |
|
86 | + 'searchLogic' => function($query, $column, $searchTerm) { |
|
87 | + $query->orWhereHas('user', function($q) use ($searchTerm) { |
|
88 | 88 | $q->where('email', 'like', '%'.$searchTerm.'%'); |
89 | 89 | }); |
90 | 90 | }, |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | $username_parts = array_filter(explode(' ', strtolower($fullName))); |
182 | 182 | $username_parts = array_slice($username_parts, -2); |
183 | 183 | |
184 | - $part1 = (! empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
185 | - $part2 = (! empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
184 | + $part1 = (!empty($username_parts[0])) ? substr($username_parts[0], 0, 3) : ''; |
|
185 | + $part2 = (!empty($username_parts[1])) ? substr($username_parts[1], 0, 8) : ''; |
|
186 | 186 | $part3 = random_int(999, 9999); |
187 | 187 | |
188 | 188 | $username = $part1.$part2.$part3; //str_shuffle to randomly shuffle all characters |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | CRUD::addField(['name' => 'name', 'label' => 'Name', 'type' => 'text']); |
36 | 36 | |
37 | - CRUD::addField([ // Select2Multiple = n-n relationship (with pivot table) |
|
37 | + CRUD::addField([// Select2Multiple = n-n relationship (with pivot table) |
|
38 | 38 | 'label' => __('Grade Types'), |
39 | 39 | 'type' => 'select2_multiple', |
40 | 40 | 'name' => 'gradeTypes', |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | 'select_all' => true, // show Select All and Clear buttons? |
48 | 48 | ]); |
49 | 49 | |
50 | - CRUD::addField([ // Select2Multiple = n-n relationship (with pivot table) |
|
50 | + CRUD::addField([// Select2Multiple = n-n relationship (with pivot table) |
|
51 | 51 | 'label' => __('Skills'), |
52 | 52 | 'type' => 'select2_multiple', |
53 | 53 | 'name' => 'skills', |
@@ -196,15 +196,15 @@ |
||
196 | 196 | |
197 | 197 | public function handle() |
198 | 198 | { |
199 | - Student::whereNull('gender_id')->chunkById(10, function ($students) { |
|
200 | - $query = $students->map(fn ($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, ' '))]); |
|
199 | + Student::whereNull('gender_id')->chunkById(10, function($students) { |
|
200 | + $query = $students->map(fn($student) => ['id' => $student->id, 'name' => $this->remove_accents(strtok($student->firstname, ' '))]); |
|
201 | 201 | |
202 | 202 | $response = Http::get('https://api.genderize.io/?name[]='.$query->pluck('name')->implode('&name[]=')); |
203 | 203 | foreach ($students as $student) { |
204 | 204 | $firstname = $query->firstWhere('id', $student->id)['name']; |
205 | 205 | |
206 | 206 | $student->update([ |
207 | - 'gender_id' => match ($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
207 | + 'gender_id' => match($response->collect()->where('name', $firstname)->where('probability', '>', 0.9)->where('count', '>', 10)->first()['gender'] ?? '-') { |
|
208 | 208 | 'male' => 2, |
209 | 209 | 'female' => 1, |
210 | 210 | default => null, |
@@ -15,7 +15,7 @@ |
||
15 | 15 | |
16 | 16 | public function styling() |
17 | 17 | { |
18 | - return match ($this->id) { |
|
18 | + return match($this->id) { |
|
19 | 19 | 1 => 'warning', |
20 | 20 | 2 => 'info', |
21 | 21 | default => 'danger', |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | parent::boot(); |
26 | 26 | |
27 | - static::addGlobalScope('order', function (Builder $builder) { |
|
27 | + static::addGlobalScope('order', function(Builder $builder) { |
|
28 | 28 | $builder->orderBy('year_id')->orderBy('order')->orderBy('id'); |
29 | 29 | }); |
30 | 30 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | ->where('courses.period_id', $this->id) |
155 | 155 | ->where('enrollments.deleted_at', null) |
156 | 156 | ->where('enrollments.parent_id', null) |
157 | - ->where(function ($query) { |
|
157 | + ->where(function($query) { |
|
158 | 158 | return $query->where('students.gender_id', 0)->orWhereNull('students.gender_id'); |
159 | 159 | }) |
160 | 160 | ->whereIn('enrollments.status_id', ['1', '2']) // filter out cancelled enrollments, todo make this configurable. |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $period = self::where('id', '<', $this->id)->orderBy('id', 'desc')->first(); |
203 | 203 | |
204 | - if (! $period == null) { |
|
204 | + if (!$period == null) { |
|
205 | 205 | return $period; |
206 | 206 | } else { |
207 | 207 | return self::first(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function getCoursesWithPendingAttendanceAttribute() |
282 | 282 | { |
283 | 283 | // get all courses for period and preload relations |
284 | - $courses = $this->courses()->where(function ($query) { |
|
284 | + $courses = $this->courses()->where(function($query) { |
|
285 | 285 | $query->where('exempt_attendance', '!=', true); |
286 | 286 | $query->where('exempt_attendance', '!=', 1); |
287 | 287 | $query->orWhereNull('exempt_attendance'); |