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 ( 0b5ddf...759348 )
by Cristian
04:01
created
src/Crud.php 1 patch
Braces   +55 added lines, -29 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
         if ($form == 'create')
94 94
         {
95 95
             $fields = $this->create_fields;
96
-        }
97
-        else
96
+        } else
98 97
         {
99 98
             $fields = $this->update_fields;
100 99
         }
@@ -123,11 +122,11 @@  discard block
 block discarded – undo
123 122
                     foreach($relation['name'] as $relation){
124 123
                         if(isset($data[$relation])){
125 124
                             $model->{$relation}()->sync($data[$relation]);
126
-                        }else{
125
+                        } else{
127 126
                              $model->{$relation}()->sync([]);
128 127
                         }
129 128
                     }
130
-                }else{
129
+                } else{
131 130
                     $model->{$relation['name']}()->sync($data[$relation['name']]);
132 131
                 }
133 132
 
@@ -305,7 +304,7 @@  discard block
 block discarded – undo
305 304
                         $fields[$k]['value'][] = $entry->{$relation};
306 305
                     }
307 306
 
308
-                }else{
307
+                } else{
309 308
                     $fields[$k]['value'] = $entry->{$field['name']};
310 309
                 }
311 310
             }
@@ -484,7 +483,9 @@  discard block
 block discarded – undo
484 483
      */
485 484
     public function setModel($model_namespace)
486 485
     {
487
-        if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404);
486
+        if (!class_exists($model_namespace)) {
487
+            throw new \Exception('This model does not exist.', 404);
488
+        }
488 489
 
489 490
         $this->model = new $model_namespace();
490 491
         $this->query = $this->model->select('*');
@@ -526,7 +527,9 @@  discard block
 block discarded – undo
526 527
     {
527 528
         $complete_route = $route.'.index';
528 529
 
529
-        if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404);
530
+        if (!\Route::has($complete_route)) {
531
+            throw new \Exception('There are no routes for this route name.', 404);
532
+        }
530 533
 
531 534
         $this->route = route($complete_route, $parameters);
532 535
         $this->initButtons();
@@ -582,8 +585,7 @@  discard block
 block discarded – undo
582 585
                 // if label and other details have been defined in the array
583 586
                 if (is_array($columns[0])) {
584 587
                     $this->addColumn($column);
585
-                }
586
-                else
588
+                } else
587 589
                 {
588 590
                     $this->addColumn([
589 591
                                     'name' => $column,
@@ -742,19 +744,20 @@  discard block
 block discarded – undo
742 744
         if (is_string($field))
743 745
         {
744 746
             $complete_field_array['name'] = $field;
745
-        }
746
-        else
747
+        } else
747 748
         {
748 749
             $complete_field_array = $field;
749 750
         }
750 751
 
751 752
         // if the label is missing, we should set it
752
-        if (!isset($complete_field_array['label']))
753
-            $complete_field_array['label'] = ucfirst($complete_field_array['name']);
753
+        if (!isset($complete_field_array['label'])) {
754
+                    $complete_field_array['label'] = ucfirst($complete_field_array['name']);
755
+        }
754 756
 
755 757
         // if the field type is missing, we should set it
756
-        if (!isset($complete_field_array['type']))
757
-            $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']);
758
+        if (!isset($complete_field_array['type'])) {
759
+                    $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']);
760
+        }
758 761
 
759 762
         // store the field information into the correct variable on the CRUD object
760 763
         switch (strtolower($form)) {
@@ -828,8 +831,9 @@  discard block
 block discarded – undo
828 831
      * @return bool  true/false
829 832
      */
830 833
     public function checkIfFieldIsFirstOfItsType($field, $fields_array) {
831
-        if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name'])
832
-            return true;
834
+        if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) {
835
+                    return true;
836
+        }
833 837
 
834 838
         return false;
835 839
     }
@@ -986,11 +990,17 @@  discard block
 block discarded – undo
986 990
      */
987 991
     public function getFieldTypeFromDbColumnType($field)
988 992
     {
989
-        if (!array_key_exists($field, $this->field_types)) return 'text';
993
+        if (!array_key_exists($field, $this->field_types)) {
994
+            return 'text';
995
+        }
990 996
 
991
-        if ($field == 'password') return 'password';
997
+        if ($field == 'password') {
998
+            return 'password';
999
+        }
992 1000
 
993
-        if ($field == 'email') return 'email';
1001
+        if ($field == 'email') {
1002
+            return 'email';
1003
+        }
994 1004
 
995 1005
         switch ($this->field_types[$field]['type'])
996 1006
         {
@@ -1063,7 +1073,9 @@  discard block
 block discarded – undo
1063 1073
         $columns = \Schema::getColumnListing($this->model->getTable());
1064 1074
         $fillable = $this->model->getFillable();
1065 1075
 
1066
-        if (!empty($fillable)) $columns = array_intersect($columns, $fillable);
1076
+        if (!empty($fillable)) {
1077
+            $columns = array_intersect($columns, $fillable);
1078
+        }
1067 1079
 
1068 1080
         // but not updated_at, deleted_at
1069 1081
         return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at']));
@@ -1391,8 +1403,11 @@  discard block
 block discarded – undo
1391 1403
 
1392 1404
             foreach ($this->{$fields} as $key => $field)
1393 1405
             {
1394
-                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();
1395
-                    else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1406
+                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) {
1407
+                    $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
1408
+                } else {
1409
+                        $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1410
+                    }
1396 1411
             }
1397 1412
         }
1398 1413
     }
@@ -1412,7 +1427,9 @@  discard block
 block discarded – undo
1412 1427
         if (!empty($this->{$type}))
1413 1428
         {
1414 1429
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
1415
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
1430
+                if (in_array($field['name'], (array)$fields)) {
1431
+                    $field = array_merge($field, $attributes);
1432
+                }
1416 1433
 
1417 1434
                 return $field;
1418 1435
             }, $this->{$type});
@@ -1439,7 +1456,9 @@  discard block
 block discarded – undo
1439 1456
 
1440 1457
             foreach ($this->sort[$items] as $item)
1441 1458
             {
1442
-                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
1459
+                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) {
1460
+                    $elements[] = $this->{$items}[$key];
1461
+                }
1443 1462
             }
1444 1463
 
1445 1464
             return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
@@ -1458,9 +1477,13 @@  discard block
 block discarded – undo
1458 1477
         $order = (array)$order;
1459 1478
         $values = $model->select('*');
1460 1479
 
1461
-        if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
1480
+        if (!empty($where)) {
1481
+            call_user_func_array([$values, $where[0]], array_slice($where, 1));
1482
+        }
1462 1483
 
1463
-        if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order);
1484
+        if (!empty($order)) {
1485
+            call_user_func_array([$values, 'orderBy'], $order);
1486
+        }
1464 1487
 
1465 1488
         return $values->get()->lists($field, $model->getKeyName())->toArray();
1466 1489
     }
@@ -1469,8 +1492,11 @@  discard block
 block discarded – undo
1469 1492
     public function syncRelations($entity)
1470 1493
     {
1471 1494
         foreach ($this->relations as $field => $relation) {
1472
-            if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1473
-                else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1495
+            if ($relation['pivot']) {
1496
+                $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1497
+            } else {
1498
+                    $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1499
+                }
1474 1500
         }
1475 1501
     }
1476 1502
 
Please login to merge, or discard this patch.