We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -301,6 +301,9 @@ discard block |
||
301 | 301 | return $this->getShowView(); |
302 | 302 | } |
303 | 303 | |
304 | + /** |
|
305 | + * @param string $view |
|
306 | + */ |
|
304 | 307 | public function setPreviewView($view) |
305 | 308 | { |
306 | 309 | return $this->setShowView($view); |
@@ -311,6 +314,9 @@ discard block |
||
311 | 314 | return $this->getEditView(); |
312 | 315 | } |
313 | 316 | |
317 | + /** |
|
318 | + * @param string $view |
|
319 | + */ |
|
314 | 320 | public function setUpdateView($view) |
315 | 321 | { |
316 | 322 | return $this->setEditView($view); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setModel($model_namespace) |
78 | 78 | { |
79 | - if (! class_exists($model_namespace)) { |
|
79 | + if (!class_exists($model_namespace)) { |
|
80 | 80 | throw new \Exception('The model does not exist.', 500); |
81 | 81 | } |
82 | 82 | |
83 | - if (! method_exists($model_namespace, 'hasCrudTrait')) { |
|
83 | + if (!method_exists($model_namespace, 'hasCrudTrait')) { |
|
84 | 84 | throw new \Exception('Please use CrudTrait on the model.', 500); |
85 | 85 | } |
86 | 86 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | $complete_route = $route.'.index'; |
145 | 145 | |
146 | - if (! \Route::has($complete_route)) { |
|
146 | + if (!\Route::has($complete_route)) { |
|
147 | 147 | throw new \Exception('There are no routes for this route name.', 404); |
148 | 148 | } |
149 | 149 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getFirstOfItsTypeInArray($type, $array) |
246 | 246 | { |
247 | - return array_first($array, function ($item) use ($type) { |
|
247 | + return array_first($array, function($item) use ($type) { |
|
248 | 248 | return $item['type'] == $type; |
249 | 249 | }); |
250 | 250 | } |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | |
262 | 262 | public function sync($type, $fields, $attributes) |
263 | 263 | { |
264 | - if (! empty($this->{$type})) { |
|
265 | - $this->{$type} = array_map(function ($field) use ($fields, $attributes) { |
|
264 | + if (!empty($this->{$type})) { |
|
265 | + $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
|
266 | 266 | if (in_array($field['name'], (array) $fields)) { |
267 | 267 | $field = array_merge($field, $attributes); |
268 | 268 | } |
@@ -294,15 +294,15 @@ discard block |
||
294 | 294 | { |
295 | 295 | $relationArray = explode('.', $relationString); |
296 | 296 | |
297 | - if (! isset($length)) { |
|
297 | + if (!isset($length)) { |
|
298 | 298 | $length = count($relationArray); |
299 | 299 | } |
300 | 300 | |
301 | - if (! isset($model)) { |
|
301 | + if (!isset($model)) { |
|
302 | 302 | $model = $this->model; |
303 | 303 | } |
304 | 304 | |
305 | - $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
305 | + $result = array_reduce(array_splice($relationArray, 0, $length), function($obj, $method) { |
|
306 | 306 | return $obj->$method()->getRelated(); |
307 | 307 | }, $model); |
308 | 308 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $relation = $model->{$firstRelationName}; |
353 | 353 | |
354 | 354 | $results = []; |
355 | - if (! empty($relation)) { |
|
355 | + if (!empty($relation)) { |
|
356 | 356 | if ($relation instanceof Collection) { |
357 | 357 | $currentResults = $relation->toArray(); |
358 | 358 | } else { |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | |
362 | 362 | array_shift($relationArray); |
363 | 363 | |
364 | - if (! empty($relationArray)) { |
|
364 | + if (!empty($relationArray)) { |
|
365 | 365 | foreach ($currentResults as $currentResult) { |
366 | 366 | $results = array_merge($results, $this->getRelationModelInstances($currentResult, implode('.', $relationArray))); |
367 | 367 | } |
@@ -2,33 +2,33 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD; |
4 | 4 | |
5 | -use Backpack\CRUD\PanelTraits\Read; |
|
6 | -use Backpack\CRUD\PanelTraits\Tabs; |
|
7 | -use Backpack\CRUD\PanelTraits\Query; |
|
8 | -use Backpack\CRUD\PanelTraits\Views; |
|
9 | 5 | use Backpack\CRUD\PanelTraits\Access; |
6 | +use Backpack\CRUD\PanelTraits\AutoFocus; |
|
7 | +use Backpack\CRUD\PanelTraits\AutoSet; |
|
8 | +use Backpack\CRUD\PanelTraits\Buttons; |
|
9 | +use Backpack\CRUD\PanelTraits\Columns; |
|
10 | 10 | use Backpack\CRUD\PanelTraits\Create; |
11 | 11 | use Backpack\CRUD\PanelTraits\Delete; |
12 | 12 | use Backpack\CRUD\PanelTraits\Errors; |
13 | +use Backpack\CRUD\PanelTraits\FakeColumns; |
|
14 | +use Backpack\CRUD\PanelTraits\FakeFields; |
|
13 | 15 | use Backpack\CRUD\PanelTraits\Fields; |
14 | -use Backpack\CRUD\PanelTraits\Search; |
|
15 | -use Backpack\CRUD\PanelTraits\Update; |
|
16 | -use Backpack\CRUD\PanelTraits\AutoSet; |
|
17 | -use Backpack\CRUD\PanelTraits\Buttons; |
|
18 | -use Backpack\CRUD\PanelTraits\Columns; |
|
19 | 16 | use Backpack\CRUD\PanelTraits\Filters; |
20 | -use Backpack\CRUD\PanelTraits\Reorder; |
|
21 | -use Backpack\CRUD\PanelTraits\Settings; |
|
22 | -use Backpack\CRUD\PanelTraits\AutoFocus; |
|
17 | +use Backpack\CRUD\PanelTraits\HeadingsAndTitles; |
|
23 | 18 | use Backpack\CRUD\PanelTraits\Macroable; |
24 | -use Backpack\CRUD\PanelTraits\FakeFields; |
|
25 | 19 | use Backpack\CRUD\PanelTraits\Operations; |
26 | -use Backpack\CRUD\PanelTraits\Validation; |
|
27 | -use Backpack\CRUD\PanelTraits\FakeColumns; |
|
20 | +use Backpack\CRUD\PanelTraits\Query; |
|
21 | +use Backpack\CRUD\PanelTraits\Read; |
|
22 | +use Backpack\CRUD\PanelTraits\Reorder; |
|
28 | 23 | use Backpack\CRUD\PanelTraits\SaveActions; |
29 | -use Illuminate\Database\Eloquent\Collection; |
|
30 | -use Backpack\CRUD\PanelTraits\HeadingsAndTitles; |
|
24 | +use Backpack\CRUD\PanelTraits\Search; |
|
25 | +use Backpack\CRUD\PanelTraits\Settings; |
|
26 | +use Backpack\CRUD\PanelTraits\Tabs; |
|
27 | +use Backpack\CRUD\PanelTraits\Update; |
|
28 | +use Backpack\CRUD\PanelTraits\Validation; |
|
29 | +use Backpack\CRUD\PanelTraits\Views; |
|
31 | 30 | use Backpack\CRUD\PanelTraits\ViewsAndRestoresRevisions; |
31 | +use Illuminate\Database\Eloquent\Collection; |
|
32 | 32 | |
33 | 33 | class CrudPanel |
34 | 34 | { |
@@ -175,6 +175,7 @@ |
||
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Set the number of rows that should be show on the list view. |
178 | + * @param integer $value |
|
178 | 179 | */ |
179 | 180 | public function setDefaultPageLength($value) |
180 | 181 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $id = $this->getCurrentEntryId(); |
40 | 40 | |
41 | - if (! $id) { |
|
41 | + if (!$id) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getEntry($id) |
56 | 56 | { |
57 | - if (! $this->entry) { |
|
57 | + if (!$this->entry) { |
|
58 | 58 | $this->entry = $this->model->findOrFail($id); |
59 | 59 | $this->entry = $this->entry->withFakes(); |
60 | 60 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | { |
200 | 200 | // If the default Page Length isn't in the menu's values, Add it the beginnin and resort all to show a croissant list. |
201 | 201 | // assume both arrays are the same length. |
202 | - if (! in_array($this->getDefaultPageLength(), $this->getOperationSetting('pageLengthMenu')[0])) { |
|
202 | + if (!in_array($this->getDefaultPageLength(), $this->getOperationSetting('pageLengthMenu')[0])) { |
|
203 | 203 | // Loop through 2 arrays of prop. page_length_menu |
204 | 204 | foreach ($this->getOperationSetting('pageLengthMenu') as $key => &$page_length_choices) { |
205 | 205 | // This is a condition that should be always true. |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function getPageLengthMenu() |
231 | 231 | { |
232 | 232 | // if already set, use that |
233 | - if (! $this->getOperationSetting('pageLengthMenu')) { |
|
233 | + if (!$this->getOperationSetting('pageLengthMenu')) { |
|
234 | 234 | // try to get the menu settings from the config file |
235 | 235 | $this->setOperationSetting('pageLengthMenu', config('backpack.crud.page_length_menu') ?? [[10, 25, 50, 100, -1], [10, 25, 50, 100, 'backpack::crud.all']]); |
236 | 236 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function getTitle($action = false) |
23 | 23 | { |
24 | - if (! $action) { |
|
24 | + if (!$action) { |
|
25 | 25 | $action = $this->getActionMethod(); |
26 | 26 | } |
27 | 27 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function setTitle($string, $action = false) |
40 | 40 | { |
41 | - if (! $action) { |
|
41 | + if (!$action) { |
|
42 | 42 | $action = $this->getActionMethod(); |
43 | 43 | } |
44 | 44 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getHeading($action = false) |
60 | 60 | { |
61 | - if (! $action) { |
|
61 | + if (!$action) { |
|
62 | 62 | $action = $this->getActionMethod(); |
63 | 63 | } |
64 | 64 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function setHeading($string, $action = false) |
77 | 77 | { |
78 | - if (! $action) { |
|
78 | + if (!$action) { |
|
79 | 79 | $action = $this->getActionMethod(); |
80 | 80 | } |
81 | 81 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getSubheading($action = false) |
97 | 97 | { |
98 | - if (! $action) { |
|
98 | + if (!$action) { |
|
99 | 99 | $action = $this->getActionMethod(); |
100 | 100 | } |
101 | 101 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function setSubheading($string, $action = false) |
114 | 114 | { |
115 | - if (! $action) { |
|
115 | + if (!$action) { |
|
116 | 116 | $action = $this->getActionMethod(); |
117 | 117 | } |
118 | 118 |
@@ -2,8 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4 | 4 | |
5 | -use Doctrine\DBAL\DBALException; |
|
6 | 5 | use Backpack\CRUD\Tests\Unit\Models\ColumnType; |
6 | +use Doctrine\DBAL\DBALException; |
|
7 | 7 | |
8 | 8 | class MyColumnTypeWithOtherConnection extends ColumnType |
9 | 9 | { |
@@ -12,6 +12,9 @@ |
||
12 | 12 | return $this->getOperationSetting('autoFocusOnFirstField'); |
13 | 13 | } |
14 | 14 | |
15 | + /** |
|
16 | + * @param boolean $value |
|
17 | + */ |
|
15 | 18 | public function setAutoFocusOnFirstField($value) |
16 | 19 | { |
17 | 20 | return $this->setOperationSetting('autoFocusOnFirstField', (bool) $value); |
@@ -62,6 +62,9 @@ discard block |
||
62 | 62 | $this->addButton($stack, $name, 'model_function', $model_function_name, $position); |
63 | 63 | } |
64 | 64 | |
65 | + /** |
|
66 | + * @param string $view |
|
67 | + */ |
|
65 | 68 | public function addButtonFromView($stack, $name, $view, $position = false) |
66 | 69 | { |
67 | 70 | $view = 'crud::buttons.'.$view; |
@@ -119,7 +122,7 @@ discard block |
||
119 | 122 | } |
120 | 123 | |
121 | 124 | /** |
122 | - * @param array $names Button names |
|
125 | + * @param string[] $names Button names |
|
123 | 126 | * @param string|null $stack Optional stack name. |
124 | 127 | */ |
125 | 128 | public function removeButtons($names, $stack = null) |
@@ -136,6 +139,9 @@ discard block |
||
136 | 139 | $this->setOperationSetting('buttons', collect()); |
137 | 140 | } |
138 | 141 | |
142 | + /** |
|
143 | + * @param string $stack |
|
144 | + */ |
|
139 | 145 | public function removeAllButtonsFromStack($stack) |
140 | 146 | { |
141 | 147 | $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($stack) { |
@@ -158,6 +164,12 @@ discard block |
||
158 | 164 | public $type = 'view'; |
159 | 165 | public $content; |
160 | 166 | |
167 | + /** |
|
168 | + * @param string $stack |
|
169 | + * @param string $name |
|
170 | + * @param string $type |
|
171 | + * @param string $content |
|
172 | + */ |
|
161 | 173 | public function __construct($stack, $name, $type, $content) |
162 | 174 | { |
163 | 175 | $this->stack = $stack; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | $button = $this->buttons()->firstWhere('name', $name); |
94 | 94 | |
95 | - if (! $button) { |
|
95 | + if (!$button) { |
|
96 | 96 | abort(500, 'CRUD Button "'.$name.'" not found. Please check the button exists before you modify it.'); |
97 | 97 | } |
98 | 98 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function removeButton($name, $stack = null) |
115 | 115 | { |
116 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($name, $stack) { |
|
116 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($name, $stack) { |
|
117 | 117 | return $stack == null ? $button->name == $name : ($button->stack == $stack) && ($button->name == $name); |
118 | 118 | })); |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function removeButtons($names, $stack = null) |
126 | 126 | { |
127 | - if (! empty($names)) { |
|
127 | + if (!empty($names)) { |
|
128 | 128 | foreach ($names as $name) { |
129 | 129 | $this->removeButton($name, $stack); |
130 | 130 | } |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | |
139 | 139 | public function removeAllButtonsFromStack($stack) |
140 | 140 | { |
141 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($stack) { |
|
141 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($stack) { |
|
142 | 142 | return $button->stack == $stack; |
143 | 143 | })); |
144 | 144 | } |
145 | 145 | |
146 | 146 | public function removeButtonFromStack($name, $stack) |
147 | 147 | { |
148 | - $this->setOperationSetting('buttons', $this->buttons()->reject(function ($button) use ($name, $stack) { |
|
148 | + $this->setOperationSetting('buttons', $this->buttons()->reject(function($button) use ($name, $stack) { |
|
149 | 149 | return $button->name == $name && $button->stack == $stack; |
150 | 150 | })); |
151 | 151 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * Move the most recently added column after the given target column. |
143 | 143 | * |
144 | - * @param string|array $targetColumn The target column name or array. |
|
144 | + * @param string $targetColumn The target column name or array. |
|
145 | 145 | */ |
146 | 146 | public function afterColumn($targetColumn) |
147 | 147 | { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Move this column to be first in the columns list. |
163 | - * @return bool|null |
|
163 | + * @return false|null |
|
164 | 164 | */ |
165 | 165 | public function makeFirstColumn() |
166 | 166 | { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * Remove a column from the CRUD panel by name. |
239 | 239 | * |
240 | - * @param string $column The column key. |
|
240 | + * @param string $columnKey The column key. |
|
241 | 241 | */ |
242 | 242 | public function removeColumn($columnKey) |
243 | 243 | { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | public function addColumn($column) |
64 | 64 | { |
65 | 65 | // if a string was passed, not an array, change it to an array |
66 | - if (! is_array($column)) { |
|
66 | + if (!is_array($column)) { |
|
67 | 67 | $column = ['name' => $column]; |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $column_with_details = $this->addDefaultLabel($column); |
72 | 72 | |
73 | 73 | // make sure the column has a name |
74 | - if (! array_key_exists('name', $column_with_details)) { |
|
74 | + if (!array_key_exists('name', $column_with_details)) { |
|
75 | 75 | $column_with_details['name'] = 'anonymous_column_'.str_random(5); |
76 | 76 | } |
77 | 77 | |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | $columnExistsInDb = $this->hasColumn($this->model->getTable(), $column_with_details['name']); |
80 | 80 | |
81 | 81 | // make sure the column has a type |
82 | - if (! array_key_exists('type', $column_with_details)) { |
|
82 | + if (!array_key_exists('type', $column_with_details)) { |
|
83 | 83 | $column_with_details['type'] = 'text'; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // make sure the column has a key |
87 | - if (! array_key_exists('key', $column_with_details)) { |
|
87 | + if (!array_key_exists('key', $column_with_details)) { |
|
88 | 88 | $column_with_details['key'] = $column_with_details['name']; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // make sure the column has a tableColumn boolean |
92 | - if (! array_key_exists('tableColumn', $column_with_details)) { |
|
92 | + if (!array_key_exists('tableColumn', $column_with_details)) { |
|
93 | 93 | $column_with_details['tableColumn'] = $columnExistsInDb ? true : false; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // make sure the column has a orderable boolean |
97 | - if (! array_key_exists('orderable', $column_with_details)) { |
|
97 | + if (!array_key_exists('orderable', $column_with_details)) { |
|
98 | 98 | $column_with_details['orderable'] = $columnExistsInDb ? true : false; |
99 | 99 | } |
100 | 100 | |
101 | 101 | // make sure the column has a searchLogic |
102 | - if (! array_key_exists('searchLogic', $column_with_details)) { |
|
102 | + if (!array_key_exists('searchLogic', $column_with_details)) { |
|
103 | 103 | $column_with_details['searchLogic'] = $columnExistsInDb ? true : false; |
104 | 104 | } |
105 | 105 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | |
109 | 109 | // make sure the column has a priority in terms of visibility |
110 | 110 | // if no priority has been defined, use the order in the array plus one |
111 | - if (! array_key_exists('priority', $column_with_details)) { |
|
111 | + if (!array_key_exists('priority', $column_with_details)) { |
|
112 | 112 | $position_in_columns_array = (int) array_search($column_with_details['key'], array_keys($this->columns())); |
113 | 113 | $columnsArray[$column_with_details['key']]['priority'] = $position_in_columns_array + 1; |
114 | 114 | } |
115 | 115 | |
116 | 116 | // if this is a relation type field and no corresponding model was specified, get it from the relation method |
117 | 117 | // defined in the main model |
118 | - if (isset($column_with_details['entity']) && ! isset($column_with_details['model'])) { |
|
118 | + if (isset($column_with_details['entity']) && !isset($column_with_details['model'])) { |
|
119 | 119 | $columnsArray[$column_with_details['key']]['model'] = $this->getRelationModel($column_with_details['entity']); |
120 | 120 | } |
121 | 121 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function makeFirstColumn() |
166 | 166 | { |
167 | - if (! $this->columns()) { |
|
167 | + if (!$this->columns()) { |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | |
@@ -186,8 +186,7 @@ discard block |
||
186 | 186 | $columnsArray = $this->columns(); |
187 | 187 | |
188 | 188 | if (array_key_exists($targetColumnName, $columnsArray)) { |
189 | - $targetColumnPosition = $before ? array_search($targetColumnName, array_keys($columnsArray)) : |
|
190 | - array_search($targetColumnName, array_keys($columnsArray)) + 1; |
|
189 | + $targetColumnPosition = $before ? array_search($targetColumnName, array_keys($columnsArray)) : array_search($targetColumnName, array_keys($columnsArray)) + 1; |
|
191 | 190 | |
192 | 191 | $element = array_pop($columnsArray); |
193 | 192 | $beginningPart = array_slice($columnsArray, 0, $targetColumnPosition, true); |
@@ -225,7 +224,7 @@ discard block |
||
225 | 224 | */ |
226 | 225 | public function addDefaultLabel($array) |
227 | 226 | { |
228 | - if (! array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) { |
|
227 | + if (!array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) { |
|
229 | 228 | $array = array_merge(['label' => mb_ucfirst($this->makeLabel($array['name']))], $array); |
230 | 229 | |
231 | 230 | return $array; |
@@ -253,7 +252,7 @@ discard block |
||
253 | 252 | */ |
254 | 253 | public function removeColumns($columns) |
255 | 254 | { |
256 | - if (! empty($columns)) { |
|
255 | + if (!empty($columns)) { |
|
257 | 256 | foreach ($columns as $columnKey) { |
258 | 257 | $this->removeColumn($columnKey); |
259 | 258 | } |
@@ -331,7 +330,7 @@ discard block |
||
331 | 330 | { |
332 | 331 | $columns = $this->columns(); |
333 | 332 | |
334 | - return collect($columns)->pluck('entity')->reject(function ($value, $key) { |
|
333 | + return collect($columns)->pluck('entity')->reject(function($value, $key) { |
|
335 | 334 | return $value == null; |
336 | 335 | })->toArray(); |
337 | 336 | } |
@@ -22,7 +22,6 @@ discard block |
||
22 | 22 | * Add a field to the create/update form or both. |
23 | 23 | * |
24 | 24 | * @param string|array $field The new field. |
25 | - * @param string $form The CRUD form. Can be 'create', 'update' or 'both'. Default is 'both'. |
|
26 | 25 | * |
27 | 26 | * @return self |
28 | 27 | */ |
@@ -70,7 +69,6 @@ discard block |
||
70 | 69 | * Add multiple fields to the create/update form or both. |
71 | 70 | * |
72 | 71 | * @param array $fields The new fields. |
73 | - * @param string $form The CRUD form. Can be 'create', 'update' or 'both'. Default is 'both'. |
|
74 | 72 | */ |
75 | 73 | public function addFields($fields) |
76 | 74 | { |
@@ -85,7 +83,6 @@ discard block |
||
85 | 83 | * Move the most recently added field after the given target field. |
86 | 84 | * |
87 | 85 | * @param string $targetFieldName The target field name. |
88 | - * @param string $form The CRUD form. Can be 'create', 'update' or 'both'. Default is 'both'. |
|
89 | 86 | */ |
90 | 87 | public function afterField($targetFieldName) |
91 | 88 | { |
@@ -98,7 +95,6 @@ discard block |
||
98 | 95 | * Move the most recently added field before the given target field. |
99 | 96 | * |
100 | 97 | * @param string $targetFieldName The target field name. |
101 | - * @param string $form The CRUD form. Can be 'create', 'update' or 'both'. Default is 'both'. |
|
102 | 98 | */ |
103 | 99 | public function beforeField($targetFieldName) |
104 | 100 | { |
@@ -141,7 +137,6 @@ discard block |
||
141 | 137 | * Remove a certain field from the create/update/both forms by its name. |
142 | 138 | * |
143 | 139 | * @param string $name Field name (as defined with the addField() procedure) |
144 | - * @param string $form update/create/both |
|
145 | 140 | */ |
146 | 141 | public function removeField($name) |
147 | 142 | { |
@@ -330,8 +325,6 @@ discard block |
||
330 | 325 | * Check if the create/update form has upload fields. |
331 | 326 | * Upload fields are the ones that have "upload" => true defined on them. |
332 | 327 | * |
333 | - * @param string $form create/update/both - defaults to 'both' |
|
334 | - * @param bool|int $id id of the entity - defaults to false |
|
335 | 328 | * |
336 | 329 | * @return bool |
337 | 330 | */ |
@@ -38,23 +38,23 @@ discard block |
||
38 | 38 | |
39 | 39 | // if this is a relation type field and no corresponding model was specified, get it from the relation method |
40 | 40 | // defined in the main model |
41 | - if (isset($newField['entity']) && ! isset($newField['model'])) { |
|
41 | + if (isset($newField['entity']) && !isset($newField['model'])) { |
|
42 | 42 | $newField['model'] = $this->getRelationModel($newField['entity']); |
43 | 43 | } |
44 | 44 | |
45 | 45 | // if the label is missing, we should set it |
46 | - if (! isset($newField['label'])) { |
|
46 | + if (!isset($newField['label'])) { |
|
47 | 47 | $newField['label'] = mb_ucfirst(str_replace('_', ' ', $newField['name'])); |
48 | 48 | } |
49 | 49 | |
50 | 50 | // if the field type is missing, we should set it |
51 | - if (! isset($newField['type'])) { |
|
51 | + if (!isset($newField['type'])) { |
|
52 | 52 | $newField['type'] = $this->getFieldTypeFromDbColumnType($newField['name']); |
53 | 53 | } |
54 | 54 | |
55 | 55 | // if a tab was mentioned, we should enable it |
56 | 56 | if (isset($newField['tab'])) { |
57 | - if (! $this->tabsEnabled()) { |
|
57 | + if (!$this->tabsEnabled()) { |
|
58 | 58 | $this->enableTabs(); |
59 | 59 | } |
60 | 60 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function afterField($targetFieldName) |
91 | 91 | { |
92 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
92 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
93 | 93 | return $this->moveField($fields, $targetFieldName, false); |
94 | 94 | }); |
95 | 95 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function beforeField($targetFieldName) |
104 | 104 | { |
105 | - $this->transformFields(function ($fields) use ($targetFieldName) { |
|
105 | + $this->transformFields(function($fields) use ($targetFieldName) { |
|
106 | 106 | return $this->moveField($fields, $targetFieldName, true); |
107 | 107 | }); |
108 | 108 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function removeField($name) |
147 | 147 | { |
148 | - $this->transformFields(function ($fields) use ($name) { |
|
148 | + $this->transformFields(function($fields) use ($name) { |
|
149 | 149 | array_forget($fields, $name); |
150 | 150 | |
151 | 151 | return $fields; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function removeFields($array_of_names) |
161 | 161 | { |
162 | - if (! empty($array_of_names)) { |
|
162 | + if (!empty($array_of_names)) { |
|
163 | 163 | foreach ($array_of_names as $name) { |
164 | 164 | $this->removeField($name); |
165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function removeAllFields() |
173 | 173 | { |
174 | 174 | $current_fields = $this->getCurrentFields(); |
175 | - if (! empty($current_fields)) { |
|
175 | + if (!empty($current_fields)) { |
|
176 | 176 | foreach ($current_fields as $field) { |
177 | 177 | $this->removeField($field['name']); |
178 | 178 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $jsonCastables = ['array', 'object', 'json']; |
247 | 247 | $fieldCasting = $casted_attributes[$field['name']]; |
248 | 248 | |
249 | - if (in_array($fieldCasting, $jsonCastables) && isset($data[$field['name']]) && ! empty($data[$field['name']]) && ! is_array($data[$field['name']])) { |
|
249 | + if (in_array($fieldCasting, $jsonCastables) && isset($data[$field['name']]) && !empty($data[$field['name']]) && !is_array($data[$field['name']])) { |
|
250 | 250 | try { |
251 | 251 | $data[$field['name']] = json_decode($data[$field['name']]); |
252 | 252 | } catch (\Exception $e) { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | public function orderFields($order) |
277 | 277 | { |
278 | - $this->transformFields(function ($fields) use ($order) { |
|
278 | + $this->transformFields(function($fields) use ($order) { |
|
279 | 279 | return $this->applyOrderToFields($fields, $order); |
280 | 280 | }); |
281 | 281 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | public function hasUploadFields() |
339 | 339 | { |
340 | 340 | $fields = $this->getFields(); |
341 | - $upload_fields = array_where($fields, function ($value, $key) { |
|
341 | + $upload_fields = array_where($fields, function($value, $key) { |
|
342 | 342 | return isset($value['upload']) && $value['upload'] == true; |
343 | 343 | }); |
344 | 344 |