Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( c61b79...4016a1 )
by Cristian
09:20
created
src/CrudTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@
 block discarded – undo
12 12
     |--------------------------------------------------------------------------
13 13
     */
14 14
 
15
-    public static function getPossibleEnumValues($field_name){
15
+    public static function getPossibleEnumValues($field_name) {
16 16
         $instance = new static; // create an instance of the model to be able to get the table name
17
-        $type = DB::select( DB::raw('SHOW COLUMNS FROM '.$instance->getTable().' WHERE Field = "'.$field_name.'"') )[0]->Type;
17
+        $type = DB::select(DB::raw('SHOW COLUMNS FROM '.$instance->getTable().' WHERE Field = "'.$field_name.'"'))[0]->Type;
18 18
         preg_match('/^enum\((.*)\)$/', $type, $matches);
19 19
         $enum = array();
20 20
         $exploded = explode(',', $matches[1]);
21
-        foreach($exploded as $value){
22
-            $v = trim( $value, "'" );
21
+        foreach ($exploded as $value) {
22
+            $v = trim($value, "'");
23 23
             $enum[] = $v;
24 24
         }
25 25
         return $enum;
Please login to merge, or discard this patch.
src/app/Http/Controllers/ExampleCrudController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 										'model' => "App\Models\Example"
158 158
 									],
159 159
 								];
160
-		$this->crud->fields =  [
160
+		$this->crud->fields = [
161 161
 								[
162 162
 									'name' => 'name',
163 163
 									'label' => "Example item text"
Please login to merge, or discard this patch.
src/Crud.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function getCreateFields()
82 82
     {
83
-        return $this->prepareFields(empty($this->create_fields)?$this->fields:$this->create_fields);
83
+        return $this->prepareFields(empty($this->create_fields) ? $this->fields : $this->create_fields);
84 84
     }
85 85
 
86 86
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
     {
91 91
         foreach ($this->relations as $key => $relation)
92 92
         {
93
-            if ($relation['pivot']){
93
+            if ($relation['pivot']) {
94 94
                 $model->{$relation['name']}()->sync($data[$key]);
95 95
 
96
-                foreach($relation['pivotFields'] as $pivotField){
97
-                   foreach($data[$pivotField] as $pivot_id =>  $field){
96
+                foreach ($relation['pivotFields'] as $pivotField) {
97
+                   foreach ($data[$pivotField] as $pivot_id =>  $field) {
98 98
                      $model->{$relation['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]);
99 99
                    }
100 100
                 }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function getUpdateFields($id)
254 254
     {
255
-        $fields = $this->prepareFields(empty($this->update_fields)?$this->fields:$this->update_fields);
255
+        $fields = $this->prepareFields(empty($this->update_fields) ? $this->fields : $this->update_fields);
256 256
         $entry = $this->getEntry($id);
257 257
 
258 258
         foreach ($fields as $k => $field) {
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
     public function allowAccess($access)
377 377
     {
378 378
         // $this->addButtons((array)$access);
379
-        return $this->access = array_merge(array_diff((array)$access, $this->access), $this->access);
379
+        return $this->access = array_merge(array_diff((array) $access, $this->access), $this->access);
380 380
     }
381 381
 
382 382
     public function denyAccess($access)
383 383
     {
384 384
         // $this->removeButtons((array)$access);
385
-        return $this->access = array_diff($this->access, (array)$access);
385
+        return $this->access = array_diff($this->access, (array) $access);
386 386
     }
387 387
 
388 388
     /**
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
      */
596 596
     public function addDefaultTypeToColumn($column)
597 597
     {
598
-        if (array_key_exists('name', (array)$column))
598
+        if (array_key_exists('name', (array) $column))
599 599
         {
600 600
             $default_type = $this->getFieldTypeFromDbColumnType($column['name']);
601 601
             return array_merge(['type' => $default_type], $column);
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
      * @param [field or column]
612 612
      */
613 613
     public function addDefaultLabel($array) {
614
-        if (!array_key_exists('label', (array)$array) && array_key_exists('name', (array)$array)) {
614
+        if (!array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) {
615 615
             $array = array_merge(['label' => ucfirst($this->makeLabel($array['name']))], $array);
616 616
             return $array;
617 617
         }
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
         array_map(function($field) {
786 786
             // $this->labels[$field] = $this->makeLabel($field);
787 787
 
788
-            $this->fields[] =  [
788
+            $this->fields[] = [
789 789
                                 'name' => $field,
790 790
                                 'label' => ucfirst($field),
791 791
                                 'value' => '', 'default' => $this->field_types[$field]['default'],
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 
1128 1128
     public function orderColumns($order)
1129 1129
     {
1130
-        $this->setSort('columns', (array)$order);
1130
+        $this->setSort('columns', (array) $order);
1131 1131
     }
1132 1132
 
1133 1133
 
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
 
1203 1203
     public function orderFields($order)
1204 1204
     {
1205
-        $this->setSort('fields', (array)$order);
1205
+        $this->setSort('fields', (array) $order);
1206 1206
     }
1207 1207
 
1208 1208
 
1209 1209
     public function syncField($field)
1210 1210
     {
1211
-        if (array_key_exists('name', (array)$field)) return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
1211
+        if (array_key_exists('name', (array) $field)) return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
1212 1212
 
1213 1213
         return false;
1214 1214
     }
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
         if (!empty($this->{$type}))
1248 1248
         {
1249 1249
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
1250
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
1250
+                if (in_array($field['name'], (array) $fields)) $field = array_merge($field, $attributes);
1251 1251
 
1252 1252
                 return $field;
1253 1253
             }, $this->{$type});
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 
1259 1259
     public function remove($entity, $fields)
1260 1260
     {
1261
-        return array_values(array_filter($this->{$entity}, function($field) use ($fields) { return !in_array($field['name'], (array)$fields);}));
1261
+        return array_values(array_filter($this->{$entity}, function($field) use ($fields) { return !in_array($field['name'], (array) $fields); }));
1262 1262
     }
1263 1263
 
1264 1264
     public function setSort($items, $order)
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
                 if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
1278 1278
             }
1279 1279
 
1280
-            return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
1280
+            return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]); }));
1281 1281
         }
1282 1282
 
1283 1283
         return $this->{$items};
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
     // cred ca ia valorile din tabela de legatura ca sa ti le afiseze in select
1291 1291
     public function getRelationValues($model, $field, $where = [], $order = [])
1292 1292
     {
1293
-        $order = (array)$order;
1293
+        $order = (array) $order;
1294 1294
         $values = $model->select('*');
1295 1295
 
1296 1296
         if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
Please login to merge, or discard this patch.
Braces   +47 added lines, -18 removed lines patch added patch discarded remove patch
@@ -238,7 +238,9 @@  discard block
 block discarded – undo
238 238
         $item = $this->model->findOrFail($id);
239 239
         $updated = $item->update($this->compactFakeFields($data));
240 240
 
241
-        if ($updated) $this->syncPivot($item, $data);
241
+        if ($updated) {
242
+            $this->syncPivot($item, $data);
243
+        }
242 244
 
243 245
         return $item;
244 246
     }
@@ -436,7 +438,9 @@  discard block
 block discarded – undo
436 438
      */
437 439
     public function setModel($model_namespace)
438 440
     {
439
-        if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404);
441
+        if (!class_exists($model_namespace)) {
442
+            throw new \Exception('This model does not exist.', 404);
443
+        }
440 444
 
441 445
         $this->model = new $model_namespace();
442 446
         $this->query = $this->model->select('*');
@@ -478,7 +482,9 @@  discard block
 block discarded – undo
478 482
     {
479 483
         $complete_route = $route.'.index';
480 484
 
481
-        if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404);
485
+        if (!\Route::has($complete_route)) {
486
+            throw new \Exception('There are no routes for this route name.', 404);
487
+        }
482 488
 
483 489
         $this->route = route($complete_route, $parameters);
484 490
         $this->initButtons();
@@ -534,8 +540,7 @@  discard block
 block discarded – undo
534 540
                 // if label and other details have been defined in the array
535 541
                 if (is_array($columns[0])) {
536 542
                     $this->addColumn($column);
537
-                }
538
-                else
543
+                } else
539 544
                 {
540 545
                     $this->addColumn([
541 546
                                     'name' => $column,
@@ -831,11 +836,17 @@  discard block
 block discarded – undo
831 836
      */
832 837
     public function getFieldTypeFromDbColumnType($field)
833 838
     {
834
-        if (!array_key_exists($field, $this->field_types)) return 'text';
839
+        if (!array_key_exists($field, $this->field_types)) {
840
+            return 'text';
841
+        }
835 842
 
836
-        if ($field == 'password') return 'password';
843
+        if ($field == 'password') {
844
+            return 'password';
845
+        }
837 846
 
838
-        if ($field == 'email') return 'email';
847
+        if ($field == 'email') {
848
+            return 'email';
849
+        }
839 850
 
840 851
         switch ($this->field_types[$field]['type'])
841 852
         {
@@ -908,7 +919,9 @@  discard block
 block discarded – undo
908 919
         $columns = \Schema::getColumnListing($this->model->getTable());
909 920
         $fillable = $this->model->getFillable();
910 921
 
911
-        if (!empty($fillable)) $columns = array_intersect($columns, $fillable);
922
+        if (!empty($fillable)) {
923
+            $columns = array_intersect($columns, $fillable);
924
+        }
912 925
 
913 926
         // but not updated_at, deleted_at
914 927
         return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at']));
@@ -1208,7 +1221,9 @@  discard block
 block discarded – undo
1208 1221
 
1209 1222
     public function syncField($field)
1210 1223
     {
1211
-        if (array_key_exists('name', (array)$field)) return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
1224
+        if (array_key_exists('name', (array)$field)) {
1225
+            return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
1226
+        }
1212 1227
 
1213 1228
         return false;
1214 1229
     }
@@ -1226,8 +1241,11 @@  discard block
 block discarded – undo
1226 1241
 
1227 1242
             foreach ($this->{$fields} as $key => $field)
1228 1243
             {
1229
-                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
1230
-                    else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1244
+                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) {
1245
+                    $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
1246
+                } else {
1247
+                        $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1248
+                    }
1231 1249
             }
1232 1250
         }
1233 1251
     }
@@ -1247,7 +1265,9 @@  discard block
 block discarded – undo
1247 1265
         if (!empty($this->{$type}))
1248 1266
         {
1249 1267
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
1250
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
1268
+                if (in_array($field['name'], (array)$fields)) {
1269
+                    $field = array_merge($field, $attributes);
1270
+                }
1251 1271
 
1252 1272
                 return $field;
1253 1273
             }, $this->{$type});
@@ -1274,7 +1294,9 @@  discard block
 block discarded – undo
1274 1294
 
1275 1295
             foreach ($this->sort[$items] as $item)
1276 1296
             {
1277
-                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
1297
+                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) {
1298
+                    $elements[] = $this->{$items}[$key];
1299
+                }
1278 1300
             }
1279 1301
 
1280 1302
             return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
@@ -1293,9 +1315,13 @@  discard block
 block discarded – undo
1293 1315
         $order = (array)$order;
1294 1316
         $values = $model->select('*');
1295 1317
 
1296
-        if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
1318
+        if (!empty($where)) {
1319
+            call_user_func_array([$values, $where[0]], array_slice($where, 1));
1320
+        }
1297 1321
 
1298
-        if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order);
1322
+        if (!empty($order)) {
1323
+            call_user_func_array([$values, 'orderBy'], $order);
1324
+        }
1299 1325
 
1300 1326
         return $values->get()->lists($field, $model->getKeyName())->toArray();
1301 1327
     }
@@ -1304,8 +1330,11 @@  discard block
 block discarded – undo
1304 1330
     public function syncRelations($entity)
1305 1331
     {
1306 1332
         foreach ($this->relations as $field => $relation) {
1307
-            if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1308
-                else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1333
+            if ($relation['pivot']) {
1334
+                $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1335
+            } else {
1336
+                    $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1337
+                }
1309 1338
         }
1310 1339
     }
1311 1340
 
Please login to merge, or discard this patch.
src/resources/views/fields/checklist_dependency.blade.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
       $dependencyArray = [];
16 16
 
17 17
       //convert dependency array to simple matrix ( prymary id as key and array with secondaries id )
18
-      foreach($dependencies as $primary){
18
+      foreach ($dependencies as $primary) {
19 19
           $dependencyArray[$primary->id] = [];
20
-        foreach($primary->{$primary_dependency['entity_secondary']} as $secondary){
20
+        foreach ($primary->{$primary_dependency['entity_secondary']} as $secondary) {
21 21
             $dependencyArray[$primary->id][] = $secondary->id;
22 22
         }
23 23
       }
24 24
 
25 25
       //for update form, get initial state of the entity
26
-      if( isset($id) && $id ){
26
+      if (isset($id) && $id) {
27 27
         
28 28
         //get entity with relations for primary dependency
29 29
         $entity_dependencies = $entity_model->with($primary_dependency['entity'])
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
         $secondary_ids = [];
40 40
         
41 41
         //create secondary dependency from primary relation, used to check what chekbox must be check from second checklist
42
-        if( old($primary_dependency['name']) ) {
43
-          foreach( old($primary_dependency['name']) as $primary_item ){
44
-            foreach($dependencyArray[$primary_item] as $second_item ){
42
+        if (old($primary_dependency['name'])) {
43
+          foreach (old($primary_dependency['name']) as $primary_item) {
44
+            foreach ($dependencyArray[$primary_item] as $second_item) {
45 45
                 $secondary_ids[$second_item] = $second_item;
46 46
             }
47 47
           }
48
-        }else{ //create dependecies from relation if not from validate error
49
-          foreach( $primary_array as $primary_item ){
50
-            foreach($primary_item[$secondary_dependency['entity']] as $second_item ){
48
+        } else { //create dependecies from relation if not from validate error
49
+          foreach ($primary_array as $primary_item) {
50
+            foreach ($primary_item[$secondary_dependency['entity']] as $second_item) {
51 51
                 $secondary_ids[$second_item['id']] = $second_item['id'];
52 52
             }
53 53
           }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
                 $secondary_ids[$second_item] = $second_item;
46 46
             }
47 47
           }
48
-        }else{ //create dependecies from relation if not from validate error
48
+        } else{ //create dependecies from relation if not from validate error
49 49
           foreach( $primary_array as $primary_item ){
50 50
             foreach($primary_item[$secondary_dependency['entity']] as $second_item ){
51 51
                 $secondary_ids[$second_item['id']] = $second_item['id'];
Please login to merge, or discard this patch.
src/resources/views/fields/checklist.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <!-- select2 -->
2 2
   <div class="form-group">
3 3
     <label>{{ $field['label'] }}</label>
4
-    <?php $entity_model = $crud->getModel();?>
4
+    <?php $entity_model = $crud->getModel(); ?>
5 5
    
6 6
     <div class="row">
7 7
         @foreach ($field['model']::all() as $connected_entity_entry)
Please login to merge, or discard this patch.
src/ToneCrud.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function removePermissions($permissions) // DONE
127 127
     {
128
-        $this->removeButtons((array)$permissions);
128
+        $this->removeButtons((array) $permissions);
129 129
 
130
-        return $this->permissions = array_diff($this->permissions, (array)$permissions);
130
+        return $this->permissions = array_diff($this->permissions, (array) $permissions);
131 131
     }
132 132
 
133 133
     public function setColumns($columns)
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     public function orderColumns($order)
160 160
     {
161
-        $this->setSort('columns', (array)$order);
161
+        $this->setSort('columns', (array) $order);
162 162
     }
163 163
 
164 164
     public function setFields($fields)
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     public function orderFields($order)
230 230
     {
231
-        $this->setSort('fields', (array)$order);
231
+        $this->setSort('fields', (array) $order);
232 232
     }
233 233
 
234 234
     public function items()
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
     public function unsetListActions($actions)
289 289
     {
290
-        return $this->listActions = array_diff($this->listActions, (array)$actions);
290
+        return $this->listActions = array_diff($this->listActions, (array) $actions);
291 291
     }
292 292
 
293 293
     public function checkListAction($action)
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
     public function setRequired($fields)
314 314
     {
315
-        $this->required = array_merge($this->required, (array)$fields);
315
+        $this->required = array_merge($this->required, (array) $fields);
316 316
     }
317 317
 
318 318
     public function required()
@@ -380,14 +380,14 @@  discard block
 block discarded – undo
380 380
 
381 381
     private function syncColumn($column)
382 382
     {
383
-        if (array_key_exists('name', (array)$column)) return array_merge(['type' => $this->getType($column['name'])], $column);
383
+        if (array_key_exists('name', (array) $column)) return array_merge(['type' => $this->getType($column['name'])], $column);
384 384
 
385 385
         return false;
386 386
     }
387 387
 
388 388
     private function syncField($field)
389 389
     {
390
-        if (array_key_exists('name', (array)$field)) return array_merge(['type' => $this->getType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
390
+        if (array_key_exists('name', (array) $field)) return array_merge(['type' => $this->getType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
391 391
 
392 392
         return false;
393 393
     }
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
         if (!empty($this->{$type}))
500 500
         {
501 501
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
502
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
502
+                if (in_array($field['name'], (array) $fields)) $field = array_merge($field, $attributes);
503 503
 
504 504
                 return $field;
505 505
             }, $this->{$type});
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
     private function remove($entity, $fields)
510 510
     {
511
-        return array_values(array_filter($this->{$entity}, function($field) use ($fields) { return !in_array($field['name'], (array)$fields);}));
511
+        return array_values(array_filter($this->{$entity}, function($field) use ($fields) { return !in_array($field['name'], (array) $fields); }));
512 512
     }
513 513
 
514 514
     private function setSort($items, $order)
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
528 528
             }
529 529
 
530
-            return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
530
+            return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]); }));
531 531
         }
532 532
 
533 533
         return $this->{$items};
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
     {
538 538
         foreach ($this->relations as $key => $relation)
539 539
         {
540
-            if ($relation['pivot']){
540
+            if ($relation['pivot']) {
541 541
                 $model->{$relation['name']}()->sync($data[$key]);
542 542
 
543
-                foreach($relation['pivotFields'] as $pivotField){
544
-                   foreach($data[$pivotField] as $pivot_id =>  $field){
543
+                foreach ($relation['pivotFields'] as $pivotField) {
544
+                   foreach ($data[$pivotField] as $pivot_id =>  $field) {
545 545
                      $model->{$relation['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]);
546 546
                    }
547 547
                 }
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 
552 552
     private function getRelationValues($model, $field, $where = [], $order = [])
553 553
     {
554
-        $order = (array)$order;
554
+        $order = (array) $order;
555 555
         $values = $model->select('*');
556 556
 
557 557
         if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
Please login to merge, or discard this patch.
Braces   +64 added lines, -22 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@  discard block
 block discarded – undo
40 40
 
41 41
     public function setModel($model)
42 42
     {
43
-        if (!class_exists($model)) throw new \Exception('This model does not exist.', 404);
43
+        if (!class_exists($model)) {
44
+            throw new \Exception('This model does not exist.', 404);
45
+        }
44 46
 
45 47
         $this->model = new $model();
46 48
         $this->query = $this->model->select('*');
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
     // TODO: make this work without having to specify "index"
57 59
     public function setRoute($route, $parameters = [])
58 60
     {
59
-        if (!\Route::has($route)) throw new \Exception('This route does not exist.', 404);
61
+        if (!\Route::has($route)) {
62
+            throw new \Exception('This route does not exist.', 404);
63
+        }
60 64
 
61 65
         $this->route = route($route, $parameters);
62 66
         $this->initButtons();
@@ -254,7 +258,9 @@  discard block
 block discarded – undo
254 258
     {
255 259
         $model = $this->model->findOrFail($id);
256 260
         $updated = $model->update($data);
257
-        if ($updated) $this->syncPivot($model, $data);
261
+        if ($updated) {
262
+            $this->syncPivot($model, $data);
263
+        }
258 264
 
259 265
         return $model;
260 266
     }
@@ -282,7 +288,9 @@  discard block
 block discarded – undo
282 288
 
283 289
     public function checkPermission($permission) // DONE
284 290
     {
285
-        if (!in_array($permission, $this->permissions)) abort(403);
291
+        if (!in_array($permission, $this->permissions)) {
292
+            abort(403);
293
+        }
286 294
     }
287 295
 
288 296
     public function unsetListActions($actions)
@@ -351,11 +359,17 @@  discard block
 block discarded – undo
351 359
 
352 360
         $this->state = 'list';
353 361
 
354
-        if (in_array('create', $segments)) $this->state = 'add';
362
+        if (in_array('create', $segments)) {
363
+            $this->state = 'add';
364
+        }
355 365
 
356
-        if (in_array('edit', $segments)) $this->state = 'edit';
366
+        if (in_array('edit', $segments)) {
367
+            $this->state = 'edit';
368
+        }
357 369
 
358
-        if (is_numeric(end($segments))) $this->state = 'view';
370
+        if (is_numeric(end($segments))) {
371
+            $this->state = 'view';
372
+        }
359 373
     }
360 374
 
361 375
     private function removeButtons($buttons)
@@ -373,21 +387,27 @@  discard block
 block discarded – undo
373 387
         $columns = \Schema::getColumnListing($this->model->getTable());
374 388
         $fillable = $this->model->getFillable();
375 389
 
376
-        if (!empty($fillable)) $columns = array_intersect($columns, $fillable);
390
+        if (!empty($fillable)) {
391
+            $columns = array_intersect($columns, $fillable);
392
+        }
377 393
 
378 394
         return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at']));
379 395
     }
380 396
 
381 397
     private function syncColumn($column)
382 398
     {
383
-        if (array_key_exists('name', (array)$column)) return array_merge(['type' => $this->getType($column['name'])], $column);
399
+        if (array_key_exists('name', (array)$column)) {
400
+            return array_merge(['type' => $this->getType($column['name'])], $column);
401
+        }
384 402
 
385 403
         return false;
386 404
     }
387 405
 
388 406
     private function syncField($field)
389 407
     {
390
-        if (array_key_exists('name', (array)$field)) return array_merge(['type' => $this->getType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
408
+        if (array_key_exists('name', (array)$field)) {
409
+            return array_merge(['type' => $this->getType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field);
410
+        }
391 411
 
392 412
         return false;
393 413
     }
@@ -404,11 +424,17 @@  discard block
 block discarded – undo
404 424
 
405 425
     private function getType($field) // DONE
406 426
     {
407
-        if (!array_key_exists($field, $this->fieldTypes)) return 'text';
427
+        if (!array_key_exists($field, $this->fieldTypes)) {
428
+            return 'text';
429
+        }
408 430
 
409
-        if ($field == 'password') return 'password';
431
+        if ($field == 'password') {
432
+            return 'password';
433
+        }
410 434
 
411
-        if ($field == 'email') return 'email';
435
+        if ($field == 'email') {
436
+            return 'email';
437
+        }
412 438
 
413 439
         switch ($this->fieldTypes[$field]['type'])
414 440
         {
@@ -466,7 +492,9 @@  discard block
 block discarded – undo
466 492
 
467 493
             $this->fields[] = ['name' => $field, 'value' => '', 'default' => $this->fieldTypes[$field]['default'], 'type' => $this->getType($field), 'values' => [], 'attributes' => []];
468 494
 
469
-            if (!in_array($field, $this->model->getHidden())) $this->columns[] = ['name' => $field, 'type' => $this->getType($field)];
495
+            if (!in_array($field, $this->model->getHidden())) {
496
+                $this->columns[] = ['name' => $field, 'type' => $this->getType($field)];
497
+            }
470 498
         }, $this->getColumns());
471 499
     }
472 500
 
@@ -478,8 +506,11 @@  discard block
 block discarded – undo
478 506
 
479 507
             foreach ($this->{$fields} as $key => $field)
480 508
             {
481
-                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) $this->{$fields}[$key]['value'] = $this->item->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
482
-                    else $this->{$fields}[$key]['value'] = $this->item->{$field['name']};
509
+                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) {
510
+                    $this->{$fields}[$key]['value'] = $this->item->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
511
+                } else {
512
+                        $this->{$fields}[$key]['value'] = $this->item->{$field['name']};
513
+                    }
483 514
             }
484 515
         }
485 516
     }
@@ -499,7 +530,9 @@  discard block
 block discarded – undo
499 530
         if (!empty($this->{$type}))
500 531
         {
501 532
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
502
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
533
+                if (in_array($field['name'], (array)$fields)) {
534
+                    $field = array_merge($field, $attributes);
535
+                }
503 536
 
504 537
                 return $field;
505 538
             }, $this->{$type});
@@ -524,7 +557,9 @@  discard block
 block discarded – undo
524 557
 
525 558
             foreach ($this->sort[$items] as $item)
526 559
             {
527
-                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
560
+                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) {
561
+                    $elements[] = $this->{$items}[$key];
562
+                }
528 563
             }
529 564
 
530 565
             return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
@@ -554,9 +589,13 @@  discard block
 block discarded – undo
554 589
         $order = (array)$order;
555 590
         $values = $model->select('*');
556 591
 
557
-        if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
592
+        if (!empty($where)) {
593
+            call_user_func_array([$values, $where[0]], array_slice($where, 1));
594
+        }
558 595
 
559
-        if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order);
596
+        if (!empty($order)) {
597
+            call_user_func_array([$values, 'orderBy'], $order);
598
+        }
560 599
 
561 600
         return $values->get()->lists($field, $model->getKeyName())->toArray();
562 601
     }
@@ -564,8 +603,11 @@  discard block
 block discarded – undo
564 603
     private function syncRelations($entity)
565 604
     {
566 605
         foreach ($this->relations as $field => $relation) {
567
-            if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
568
-                else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
606
+            if ($relation['pivot']) {
607
+                $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
608
+            } else {
609
+                    $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
610
+                }
569 611
         }
570 612
     }
571 613
 
Please login to merge, or discard this patch.