Passed
Push — master ( 50ec6a...ab58f2 )
by Thomas
08:07
created
app/Http/Controllers/Admin/EnrollmentCrudController.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -93,103 +93,103 @@  discard block
 block discarded – undo
93 93
             $currency = ['suffix' => config('app.currency_symbol')];
94 94
         }
95 95
 
96
-        CRUD::addColumns([['name' => 'id', 'label' => 'ID', 'wrapper' => ['element' => function ($crud, $column, $entry) {
96
+        CRUD::addColumns([['name' => 'id', 'label' => 'ID', 'wrapper' => ['element' => function($crud, $column, $entry) {
97 97
             return $entry->status_id > 2 ? 'del' : 'span';
98
-        },],],
98
+        },], ],
99 99
 
100
-            ['label' => __('ID number'), 'type' => 'text', 'name' => 'student.idnumber', 'wrapper' => ['element' => function ($crud, $column, $entry) {
100
+            ['label' => __('ID number'), 'type' => 'text', 'name' => 'student.idnumber', 'wrapper' => ['element' => function($crud, $column, $entry) {
101 101
                 return $entry->status_id > 2 ? 'del' : 'span';
102
-            },],],
102
+            },], ],
103 103
 
104
-            ['name' => 'user', 'key' => 'user_lastname', 'attribute' => 'lastname', 'label' => __('Last Name'), 'type' => 'relationship', 'wrapper' => ['element' => function ($crud, $column, $entry) {
104
+            ['name' => 'user', 'key' => 'user_lastname', 'attribute' => 'lastname', 'label' => __('Last Name'), 'type' => 'relationship', 'wrapper' => ['element' => function($crud, $column, $entry) {
105 105
                 return $entry->status_id > 2 ? 'del' : 'span';
106 106
             },],
107 107
                 'orderable'  => true,
108
-                'orderLogic' => function ($query, $column, $columnDirection) {
108
+                'orderLogic' => function($query, $column, $columnDirection) {
109 109
                     return $query->leftJoin('users', 'enrollments.student_id', '=', 'users.id')
110 110
                         ->orderBy('users.lastname', $columnDirection)->select('enrollments.*');
111 111
                 },
112
-                'searchLogic' => function ($query, $column, $searchTerm) {
113
-                $query->orWhereHas('student', function ($q) use ($searchTerm) {
114
-                    $q->whereHas('user', function ($q) use ($searchTerm) {
115
-                        $q->where('lastname', 'like', '%' . $searchTerm . '%');
112
+                'searchLogic' => function($query, $column, $searchTerm) {
113
+                $query->orWhereHas('student', function($q) use ($searchTerm) {
114
+                    $q->whereHas('user', function($q) use ($searchTerm) {
115
+                        $q->where('lastname', 'like', '%'.$searchTerm.'%');
116 116
                     });
117 117
                 });
118 118
             },],
119 119
 
120
-            ['name' => 'user', 'key' => 'user_firstname', 'attribute' => 'firstname', 'label' => __('First Name'), 'type' => 'relationship', 'wrapper' => ['element' => function ($crud, $column, $entry) {
120
+            ['name' => 'user', 'key' => 'user_firstname', 'attribute' => 'firstname', 'label' => __('First Name'), 'type' => 'relationship', 'wrapper' => ['element' => function($crud, $column, $entry) {
121 121
                 return $entry->status_id > 2 ? 'del' : 'span';
122 122
             },],
123
-                'searchLogic' => function ($query, $column, $searchTerm) {
124
-                $query->orWhereHas('student', function ($q) use ($searchTerm) {
125
-                    $q->whereHas('user', function ($q) use ($searchTerm) {
126
-                        $q->where('firstname', 'like', '%' . $searchTerm . '%');
123
+                'searchLogic' => function($query, $column, $searchTerm) {
124
+                $query->orWhereHas('student', function($q) use ($searchTerm) {
125
+                    $q->whereHas('user', function($q) use ($searchTerm) {
126
+                        $q->where('firstname', 'like', '%'.$searchTerm.'%');
127 127
                     });
128 128
                 });
129 129
             },
130
-                'orderLogic' => function ($query, $column, $columnDirection) {
130
+                'orderLogic' => function($query, $column, $columnDirection) {
131 131
                     return $query->leftJoin('users', 'enrollments.student_id', '=', 'users.id')
132 132
                         ->orderBy('users.firstname', $columnDirection)->select('enrollments.*');
133 133
                 },
134 134
                 'orderable'  => true,
135 135
                 ],
136 136
 
137
-            ['label' => __('Age'), 'name' => 'student_age',],
137
+            ['label' => __('Age'), 'name' => 'student_age', ],
138 138
 
139
-            ['label' => __('Birthdate'), 'name' => 'student_birthdate',],]);
139
+            ['label' => __('Birthdate'), 'name' => 'student_birthdate', ], ]);
140 140
 
141 141
         if ($this->mode === 'global') {
142
-            CRUD::addColumns([['label' => __('Course'), 'type' => 'select', 'name' => 'course_id', 'entity' => 'course', 'attribute' => 'name', 'model' => Course::class,],
142
+            CRUD::addColumns([['label' => __('Course'), 'type' => 'select', 'name' => 'course_id', 'entity' => 'course', 'attribute' => 'name', 'model' => Course::class, ],
143 143
                 ['type' => 'relationship', 'name' => 'course.period', 'label' => __('Period'), 'attribute' => 'name',
144
-                    'orderLogic' => function ($query, $column, $columnDirection) {
144
+                    'orderLogic' => function($query, $column, $columnDirection) {
145 145
                         return $query->leftJoin('courses', 'enrollments.course_id', '=', 'courses.id')
146 146
                             ->orderBy('courses.period_id', $columnDirection)->select('enrollments.*');
147 147
                     },
148 148
                     'orderable'  => true,
149
-                    ],]);
149
+                    ], ]);
150 150
         }
151 151
 
152
-        CRUD::addColumns([['label' => __('Status'), 'type' => 'select', 'name' => 'status_id', 'entity' => 'enrollmentStatus', 'attribute' => 'name', 'model' => EnrollmentStatusType::class, 'wrapper' => ['element' => 'span', 'class' => function ($crud, $column, $entry) {
153
-            return 'badge badge-pill badge-' . $entry->enrollmentStatus->styling();
154
-        },],],]);
152
+        CRUD::addColumns([['label' => __('Status'), 'type' => 'select', 'name' => 'status_id', 'entity' => 'enrollmentStatus', 'attribute' => 'name', 'model' => EnrollmentStatusType::class, 'wrapper' => ['element' => 'span', 'class' => function($crud, $column, $entry) {
153
+            return 'badge badge-pill badge-'.$entry->enrollmentStatus->styling();
154
+        },], ], ]);
155 155
 
156 156
         if (config('invoicing.allow_scheduled_payments')) {
157 157
             CRUD::addColumn(['name' => 'scheduledPayments', 'type' => 'relationship', 'label' => __('Scheduled Payments'), // OPTIONAL
158
-                'attribute' => 'date', 'model' => ScheduledPayment::class,]);
158
+                'attribute' => 'date', 'model' => ScheduledPayment::class, ]);
159 159
         }
160 160
 
161 161
         CRUD::addColumn(array_merge(['name' => 'price', // The db column name
162
-            'label' => __('Price'), 'type' => 'number',], $currency));
162
+            'label' => __('Price'), 'type' => 'number', ], $currency));
163 163
 
164 164
 
165 165
         if (config('invoicing.invoices_contain_enrollments_only')) {
166
-            CRUD::addColumn(array_merge(['name' => 'balance', 'label' => __('Balance'), 'type' => 'number',], $currency));
166
+            CRUD::addColumn(array_merge(['name' => 'balance', 'label' => __('Balance'), 'type' => 'number', ], $currency));
167 167
         }
168 168
 
169 169
         CRUD::addColumns([
170 170
 
171
-            ['name' => 'scholarships', 'type' => 'relationship', 'label' => __('Scholarship'), 'attribute' => 'name', 'model' => Scholarship::class,],
171
+            ['name' => 'scholarships', 'type' => 'relationship', 'label' => __('Scholarship'), 'attribute' => 'name', 'model' => Scholarship::class, ],
172 172
 
173
-            ['label' => __('Email'), 'name' => 'user', 'attribute' => 'email', 'type' => 'relationship',],
173
+            ['label' => __('Email'), 'name' => 'user', 'attribute' => 'email', 'type' => 'relationship', ],
174 174
 
175
-            ['label' => __('Phone Number'), 'type' => 'select_multiple', 'name' => 'student.phone', 'attribute' => 'phone_number', 'model' => PhoneNumber::class,],]);
175
+            ['label' => __('Phone Number'), 'type' => 'select_multiple', 'name' => 'student.phone', 'attribute' => 'phone_number', 'model' => PhoneNumber::class, ], ]);
176 176
 
177 177
         if ($this->mode === 'global') {
178
-            CRUD::addFilter(['name' => 'status_id', 'type' => 'select2_multiple', 'label' => __('Status'),], fn() => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), function ($values) {
178
+            CRUD::addFilter(['name' => 'status_id', 'type' => 'select2_multiple', 'label' => __('Status'), ], fn() => EnrollmentStatusType::all()->pluck('name', 'id')->toArray(), function($values) {
179 179
                 foreach (json_decode($values, null, 512, JSON_THROW_ON_ERROR) as $value) {
180 180
                     CRUD::addClause('orWhere', 'status_id', $value);
181 181
                 }
182 182
             });
183 183
 
184
-            CRUD::addFilter(['name' => 'period_id', 'type' => 'select2', 'label' => __('Period'),], fn() => Period::all()->pluck('name', 'id')->toArray(), function ($value) {
184
+            CRUD::addFilter(['name' => 'period_id', 'type' => 'select2', 'label' => __('Period'), ], fn() => Period::all()->pluck('name', 'id')->toArray(), function($value) {
185 185
                 CRUD::addClause('period', $value);
186 186
             });
187 187
 
188
-            CRUD::addFilter(['name' => 'scholarship', 'type' => 'select2', 'label' => __('Scholarship'),], fn() => Scholarship::all()->pluck('name', 'id')->toArray(), function ($value) { // if the filter is active
188
+            CRUD::addFilter(['name' => 'scholarship', 'type' => 'select2', 'label' => __('Scholarship'), ], fn() => Scholarship::all()->pluck('name', 'id')->toArray(), function($value) { // if the filter is active
189 189
                 if ($value == 'all') {
190 190
                     CRUD::addClause('whereHas', 'scholarships');
191 191
                 } else {
192
-                    CRUD::addClause('whereHas', 'scholarships', function ($q) use ($value) {
192
+                    CRUD::addClause('whereHas', 'scholarships', function($q) use ($value) {
193 193
                         $q->where('scholarships.id', $value);
194 194
                     });
195 195
                 }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             'model'     => Course::class,
235 235
             'attribute' => 'name',
236 236
 
237
-            'options'   => (fn ($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()),
237
+            'options'   => (fn($query) => $query->orderBy('level_id', 'ASC')->where('period_id', $this->crud->getCurrentEntry()->course->period_id)->get()),
238 238
         ]);
239 239
 
240 240
         CRUD::addField(array_merge([
Please login to merge, or discard this patch.
app/Http/Controllers/Admin/InvoiceCrudController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         CRUD::setModel(Invoice::class);
30 30
         CRUD::setRoute(config('backpack.base.route_prefix').'/invoice');
31 31
         CRUD::setEntityNameStrings(__('invoice'), __('invoices'));
32
-        if (! config('invoicing.price_categories_enabled')) {
32
+        if (!config('invoicing.price_categories_enabled')) {
33 33
             $this->crud->addButtonFromView('top', 'createInvoice', 'createInvoice', 'start');
34 34
         }
35 35
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                 'label'=> __('Date range'),
105 105
             ],
106 106
             false,
107
-            function ($value) { // if the filter is active, apply these constraints
107
+            function($value) { // if the filter is active, apply these constraints
108 108
                 $dates = json_decode($value, null, 512, JSON_THROW_ON_ERROR);
109 109
 
110 110
                 if ($dates->from) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         $invoice = Invoice::findOrFail($id)->load('payments');
149 149
 
150
-        if (! backpack_user()->can('enrollments.edit')) {
150
+        if (!backpack_user()->can('enrollments.edit')) {
151 151
             abort(403);
152 152
         }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             'invoice' => $invoice,
156 156
             'availablePaymentMethods' => Paymentmethod::all(),
157 157
             'editable' => true,
158
-            'enrollment' => $invoice->enrollments->first()?->product,
158
+            'enrollment' => $invoice->enrollments->first() ? ->product,
159 159
             'afterSuccessUrl' => $invoice->enrollments->count() > 0 ? "/enrollment/{$invoice->enrollments->first()->product_id}/show" : '/invoice', // TODO fix this, an invoice can theoretically contain several enrollments
160 160
         ]);
161 161
     }
Please login to merge, or discard this patch.