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 ( 3195c5...0b5ddf )
by Cristian
02:56
created
src/Crud.php 2 patches
Doc Comments   +21 added lines, -4 removed lines patch added patch discarded remove patch
@@ -334,6 +334,7 @@  discard block
 block discarded – undo
334 334
      * Delete a row from the database.
335 335
      *
336 336
      * @param  [int] The id of the item to be deleted.
337
+     * @param integer $id
337 338
      * @return [bool] Deletion confirmation.
338 339
      *
339 340
      * TODO: should this delete items with relations to it too?
@@ -452,7 +453,8 @@  discard block
 block discarded – undo
452 453
      * Check if a permission is enabled for a Crud Panel. Fail if not.
453 454
      *
454 455
      * @param  [string] Permission.
455
-     * @return boolean
456
+     * @param string $permission
457
+     * @return boolean|null
456 458
      */
457 459
     public function hasAccessOrFail($permission)
458 460
     {
@@ -481,6 +483,7 @@  discard block
 block discarded – undo
481 483
      * All Create-Read-Update-Delete operations are done using that Eloquent Collection.
482 484
      *
483 485
      * @param [string] Full model namespace. Ex: App\Models\Article
486
+     * @param string $model_namespace
484 487
      */
485 488
     public function setModel($model_namespace)
486 489
     {
@@ -508,6 +511,7 @@  discard block
 block discarded – undo
508 511
      *
509 512
      * @param [string] Route name.
510 513
      * @param [array] Parameters.
514
+     * @param string $route
511 515
      */
512 516
     public function setRoute($route)
513 517
     {
@@ -540,7 +544,7 @@  discard block
 block discarded – undo
540 544
      * - $this->crud->setRouteName('admin.article')
541 545
      * - $this->crud->route = "admin/article"
542 546
      *
543
-     * @return [string]
547
+     * @return string
544 548
      */
545 549
     public function getRoute()
546 550
     {
@@ -553,6 +557,8 @@  discard block
 block discarded – undo
553 557
      *
554 558
      * @param [string] Entity name, in singular. Ex: article
555 559
      * @param [string] Entity name, in plural. Ex: articles
560
+     * @param string $singular
561
+     * @param string $plural
556 562
      */
557 563
     public function setEntityNameStrings($singular, $plural) {
558 564
         $this->entity_name = $singular;
@@ -731,8 +737,6 @@  discard block
 block discarded – undo
731 737
 
732 738
     /**
733 739
      * Add a field to the create/update form or both.
734
-     * @param [string] $name    Field name (the column name in the db in most cases)
735
-     * @param [array] $options Field-type-specific information.
736 740
      * @param string $form    The form to add the field to (create/update/both)
737 741
      */
738 742
     public function addField($field, $form='both')
@@ -1374,6 +1378,9 @@  discard block
 block discarded – undo
1374 1378
     //     return array_filter($this->{$entity}[] = $this->syncField($field));
1375 1379
     // }
1376 1380
 
1381
+    /**
1382
+     * @param string $entity
1383
+     */
1377 1384
     public function addMultiple($entity, $field)
1378 1385
     {
1379 1386
         $this->{$entity} = array_filter(array_map([$this, 'syncField'], $fields));
@@ -1398,11 +1405,17 @@  discard block
 block discarded – undo
1398 1405
     //     return array_values(array_filter($this->{$entity}, function($field) use ($fields) { return !in_array($field['name'], (array)$fields);}));
1399 1406
     // }
1400 1407
 
1408
+    /**
1409
+     * @param string $items
1410
+     */
1401 1411
     public function setSort($items, $order)
1402 1412
     {
1403 1413
         $this->sort[$items] = $order;
1404 1414
     }
1405 1415
 
1416
+    /**
1417
+     * @param string $items
1418
+     */
1406 1419
     public function sort($items)
1407 1420
     {
1408 1421
         if (array_key_exists($items, $this->sort))
@@ -1438,6 +1451,10 @@  discard block
 block discarded – undo
1438 1451
     }
1439 1452
 
1440 1453
     // face un fel de merge intre ce ii dai si ce e in CRUD
1454
+
1455
+    /**
1456
+     * @param string $entity
1457
+     */
1441 1458
     public function syncRelations($entity)
1442 1459
     {
1443 1460
         foreach ($this->relations as $field => $relation) {
Please login to merge, or discard this patch.
Braces   +52 added lines, -27 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)) {
@@ -970,11 +973,17 @@  discard block
 block discarded – undo
970 973
      */
971 974
     public function getFieldTypeFromDbColumnType($field)
972 975
     {
973
-        if (!array_key_exists($field, $this->field_types)) return 'text';
976
+        if (!array_key_exists($field, $this->field_types)) {
977
+            return 'text';
978
+        }
974 979
 
975
-        if ($field == 'password') return 'password';
980
+        if ($field == 'password') {
981
+            return 'password';
982
+        }
976 983
 
977
-        if ($field == 'email') return 'email';
984
+        if ($field == 'email') {
985
+            return 'email';
986
+        }
978 987
 
979 988
         switch ($this->field_types[$field]['type'])
980 989
         {
@@ -1047,7 +1056,9 @@  discard block
 block discarded – undo
1047 1056
         $columns = \Schema::getColumnListing($this->model->getTable());
1048 1057
         $fillable = $this->model->getFillable();
1049 1058
 
1050
-        if (!empty($fillable)) $columns = array_intersect($columns, $fillable);
1059
+        if (!empty($fillable)) {
1060
+            $columns = array_intersect($columns, $fillable);
1061
+        }
1051 1062
 
1052 1063
         // but not updated_at, deleted_at
1053 1064
         return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at']));
@@ -1363,8 +1374,11 @@  discard block
 block discarded – undo
1363 1374
 
1364 1375
             foreach ($this->{$fields} as $key => $field)
1365 1376
             {
1366
-                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();
1367
-                    else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1377
+                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) {
1378
+                    $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray();
1379
+                } else {
1380
+                        $this->{$fields}[$key]['value'] = $this->entry->{$field['name']};
1381
+                    }
1368 1382
             }
1369 1383
         }
1370 1384
     }
@@ -1384,7 +1398,9 @@  discard block
 block discarded – undo
1384 1398
         if (!empty($this->{$type}))
1385 1399
         {
1386 1400
             $this->{$type} = array_map(function($field) use ($fields, $attributes) {
1387
-                if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes);
1401
+                if (in_array($field['name'], (array)$fields)) {
1402
+                    $field = array_merge($field, $attributes);
1403
+                }
1388 1404
 
1389 1405
                 return $field;
1390 1406
             }, $this->{$type});
@@ -1411,7 +1427,9 @@  discard block
 block discarded – undo
1411 1427
 
1412 1428
             foreach ($this->sort[$items] as $item)
1413 1429
             {
1414
-                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key];
1430
+                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) {
1431
+                    $elements[] = $this->{$items}[$key];
1432
+                }
1415 1433
             }
1416 1434
 
1417 1435
             return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);}));
@@ -1430,9 +1448,13 @@  discard block
 block discarded – undo
1430 1448
         $order = (array)$order;
1431 1449
         $values = $model->select('*');
1432 1450
 
1433
-        if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1));
1451
+        if (!empty($where)) {
1452
+            call_user_func_array([$values, $where[0]], array_slice($where, 1));
1453
+        }
1434 1454
 
1435
-        if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order);
1455
+        if (!empty($order)) {
1456
+            call_user_func_array([$values, 'orderBy'], $order);
1457
+        }
1436 1458
 
1437 1459
         return $values->get()->lists($field, $model->getKeyName())->toArray();
1438 1460
     }
@@ -1441,8 +1463,11 @@  discard block
 block discarded – undo
1441 1463
     public function syncRelations($entity)
1442 1464
     {
1443 1465
         foreach ($this->relations as $field => $relation) {
1444
-            if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1445
-                else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1466
+            if ($relation['pivot']) {
1467
+                $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]);
1468
+            } else {
1469
+                    $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]);
1470
+                }
1446 1471
         }
1447 1472
     }
1448 1473
 
Please login to merge, or discard this patch.