We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -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 | } |
@@ -123,11 +122,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |