We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -71,8 +71,7 @@ |
||
71 | 71 | if ($results && $results->count()) { |
72 | 72 | $results_array = $results->lists($column['attribute'], 'id'); |
73 | 73 | echo implode(', ', $results_array->toArray()); |
74 | - } |
|
75 | - else |
|
74 | + } else |
|
76 | 75 | { |
77 | 76 | echo '-'; |
78 | 77 | } |
@@ -161,7 +161,7 @@ |
||
161 | 161 | * Remove the specified resource from storage. |
162 | 162 | * |
163 | 163 | * @param int $id |
164 | - * @return string |
|
164 | + * @return \Illuminate\Http\Response |
|
165 | 165 | */ |
166 | 166 | public function destroy($id) |
167 | 167 | { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * Store a newly created resource in storage. |
55 | 55 | * |
56 | 56 | * @param \Illuminate\Http\Request $request |
57 | - * @return \Illuminate\Http\Response |
|
57 | + * @return \Illuminate\Http\RedirectResponse |
|
58 | 58 | */ |
59 | 59 | public function crudStore(Request $request = null) |
60 | 60 | { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @param \Illuminate\Http\Request $request |
103 | 103 | * @param int $id |
104 | - * @return \Illuminate\Http\Response |
|
104 | + * @return \Illuminate\Http\RedirectResponse |
|
105 | 105 | */ |
106 | 106 | public function crudUpdate($parentId, $id, Request $request = null) |
107 | 107 | { |
@@ -45,7 +45,7 @@ |
||
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']; |
@@ -334,6 +334,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) { |
@@ -93,8 +93,7 @@ discard block |
||
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 | } |
@@ -308,7 +307,7 @@ discard block |
||
308 | 307 | $fields[$k]['value'][] = $entry->{$subfield['name']}; |
309 | 308 | } |
310 | 309 | |
311 | - }else{ |
|
310 | + } else{ |
|
312 | 311 | $fields[$k]['value'] = $entry->{$field['name']}; |
313 | 312 | } |
314 | 313 | } |
@@ -487,7 +486,9 @@ discard block |
||
487 | 486 | */ |
488 | 487 | public function setModel($model_namespace) |
489 | 488 | { |
490 | - if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404); |
|
489 | + if (!class_exists($model_namespace)) { |
|
490 | + throw new \Exception('This model does not exist.', 404); |
|
491 | + } |
|
491 | 492 | |
492 | 493 | $this->model = new $model_namespace(); |
493 | 494 | $this->query = $this->model->select('*'); |
@@ -529,7 +530,9 @@ discard block |
||
529 | 530 | { |
530 | 531 | $complete_route = $route.'.index'; |
531 | 532 | |
532 | - if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404); |
|
533 | + if (!\Route::has($complete_route)) { |
|
534 | + throw new \Exception('There are no routes for this route name.', 404); |
|
535 | + } |
|
533 | 536 | |
534 | 537 | $this->route = route($complete_route, $parameters); |
535 | 538 | $this->initButtons(); |
@@ -585,8 +588,7 @@ discard block |
||
585 | 588 | // if label and other details have been defined in the array |
586 | 589 | if (is_array($columns[0])) { |
587 | 590 | $this->addColumn($column); |
588 | - } |
|
589 | - else |
|
591 | + } else |
|
590 | 592 | { |
591 | 593 | $this->addColumn([ |
592 | 594 | 'name' => $column, |
@@ -745,19 +747,20 @@ discard block |
||
745 | 747 | if (is_string($field)) |
746 | 748 | { |
747 | 749 | $complete_field_array['name'] = $field; |
748 | - } |
|
749 | - else |
|
750 | + } else |
|
750 | 751 | { |
751 | 752 | $complete_field_array = $field; |
752 | 753 | } |
753 | 754 | |
754 | 755 | // if the label is missing, we should set it |
755 | - if (!isset($complete_field_array['label'])) |
|
756 | - $complete_field_array['label'] = ucfirst($complete_field_array['name']); |
|
756 | + if (!isset($complete_field_array['label'])) { |
|
757 | + $complete_field_array['label'] = ucfirst($complete_field_array['name']); |
|
758 | + } |
|
757 | 759 | |
758 | 760 | // if the field type is missing, we should set it |
759 | - if (!isset($complete_field_array['type'])) |
|
760 | - $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); |
|
761 | + if (!isset($complete_field_array['type'])) { |
|
762 | + $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); |
|
763 | + } |
|
761 | 764 | |
762 | 765 | // store the field information into the correct variable on the CRUD object |
763 | 766 | switch (strtolower($form)) { |
@@ -840,8 +843,9 @@ discard block |
||
840 | 843 | * @return bool true/false |
841 | 844 | */ |
842 | 845 | public function checkIfFieldIsFirstOfItsType($field, $fields_array) { |
843 | - if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) |
|
844 | - return true; |
|
846 | + if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) { |
|
847 | + return true; |
|
848 | + } |
|
845 | 849 | |
846 | 850 | return false; |
847 | 851 | } |
@@ -998,11 +1002,17 @@ discard block |
||
998 | 1002 | */ |
999 | 1003 | public function getFieldTypeFromDbColumnType($field) |
1000 | 1004 | { |
1001 | - if (!array_key_exists($field, $this->field_types)) return 'text'; |
|
1005 | + if (!array_key_exists($field, $this->field_types)) { |
|
1006 | + return 'text'; |
|
1007 | + } |
|
1002 | 1008 | |
1003 | - if ($field == 'password') return 'password'; |
|
1009 | + if ($field == 'password') { |
|
1010 | + return 'password'; |
|
1011 | + } |
|
1004 | 1012 | |
1005 | - if ($field == 'email') return 'email'; |
|
1013 | + if ($field == 'email') { |
|
1014 | + return 'email'; |
|
1015 | + } |
|
1006 | 1016 | |
1007 | 1017 | switch ($this->field_types[$field]['type']) |
1008 | 1018 | { |
@@ -1075,7 +1085,9 @@ discard block |
||
1075 | 1085 | $columns = \Schema::getColumnListing($this->model->getTable()); |
1076 | 1086 | $fillable = $this->model->getFillable(); |
1077 | 1087 | |
1078 | - if (!empty($fillable)) $columns = array_intersect($columns, $fillable); |
|
1088 | + if (!empty($fillable)) { |
|
1089 | + $columns = array_intersect($columns, $fillable); |
|
1090 | + } |
|
1079 | 1091 | |
1080 | 1092 | // but not updated_at, deleted_at |
1081 | 1093 | return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at'])); |
@@ -1403,8 +1415,11 @@ discard block |
||
1403 | 1415 | |
1404 | 1416 | foreach ($this->{$fields} as $key => $field) |
1405 | 1417 | { |
1406 | - 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(); |
|
1407 | - else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1418 | + if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) { |
|
1419 | + $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); |
|
1420 | + } else { |
|
1421 | + $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1422 | + } |
|
1408 | 1423 | } |
1409 | 1424 | } |
1410 | 1425 | } |
@@ -1424,7 +1439,9 @@ discard block |
||
1424 | 1439 | if (!empty($this->{$type})) |
1425 | 1440 | { |
1426 | 1441 | $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
1427 | - if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes); |
|
1442 | + if (in_array($field['name'], (array)$fields)) { |
|
1443 | + $field = array_merge($field, $attributes); |
|
1444 | + } |
|
1428 | 1445 | |
1429 | 1446 | return $field; |
1430 | 1447 | }, $this->{$type}); |
@@ -1451,7 +1468,9 @@ discard block |
||
1451 | 1468 | |
1452 | 1469 | foreach ($this->sort[$items] as $item) |
1453 | 1470 | { |
1454 | - if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key]; |
|
1471 | + if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) { |
|
1472 | + $elements[] = $this->{$items}[$key]; |
|
1473 | + } |
|
1455 | 1474 | } |
1456 | 1475 | |
1457 | 1476 | return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);})); |
@@ -1470,9 +1489,13 @@ discard block |
||
1470 | 1489 | $order = (array)$order; |
1471 | 1490 | $values = $model->select('*'); |
1472 | 1491 | |
1473 | - if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1492 | + if (!empty($where)) { |
|
1493 | + call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1494 | + } |
|
1474 | 1495 | |
1475 | - if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order); |
|
1496 | + if (!empty($order)) { |
|
1497 | + call_user_func_array([$values, 'orderBy'], $order); |
|
1498 | + } |
|
1476 | 1499 | |
1477 | 1500 | return $values->get()->lists($field, $model->getKeyName())->toArray(); |
1478 | 1501 | } |
@@ -1481,8 +1504,11 @@ discard block |
||
1481 | 1504 | public function syncRelations($entity) |
1482 | 1505 | { |
1483 | 1506 | foreach ($this->relations as $field => $relation) { |
1484 | - if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1485 | - else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1507 | + if ($relation['pivot']) { |
|
1508 | + $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1509 | + } else { |
|
1510 | + $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1511 | + } |
|
1486 | 1512 | } |
1487 | 1513 | } |
1488 | 1514 |