We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -24,19 +24,19 @@ |
||
24 | 24 | if (isset($field['fake']) && $field['fake'] == true) { |
25 | 25 | // add it to the request in its appropriate variable - the one defined, if defined |
26 | 26 | if (isset($field['store_in'])) { |
27 | - if (! in_array($field['store_in'], $fakeFieldsColumnsArray, true)) { |
|
27 | + if (!in_array($field['store_in'], $fakeFieldsColumnsArray, true)) { |
|
28 | 28 | array_push($fakeFieldsColumnsArray, $field['store_in']); |
29 | 29 | } |
30 | 30 | } else { |
31 | 31 | //otherwise in the one defined in the $crud variable |
32 | - if (! in_array('extras', $fakeFieldsColumnsArray, true)) { |
|
32 | + if (!in_array('extras', $fakeFieldsColumnsArray, true)) { |
|
33 | 33 | array_push($fakeFieldsColumnsArray, 'extras'); |
34 | 34 | } |
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - if (! count($fakeFieldsColumnsArray)) { |
|
39 | + if (!count($fakeFieldsColumnsArray)) { |
|
40 | 40 | $fakeFieldsColumnsArray = ['extras']; |
41 | 41 | } |
42 | 42 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * been found. |
10 | 10 | * |
11 | 11 | * @param string $form The CRUD form. Can be 'create', 'update' or 'both'. Default is 'create'. |
12 | - * @param int|bool $id Optional entity ID needed in the case of the update form. |
|
12 | + * @param integer $id Optional entity ID needed in the case of the update form. |
|
13 | 13 | * @return array The fake columns array. |
14 | 14 | */ |
15 | 15 | public function getFakeColumnsAsArray($form = 'create', $id = false) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function removeButton($name, $stack = null) |
96 | 96 | { |
97 | - $this->buttons = $this->buttons->reject(function ($button) use ($name, $stack) { |
|
97 | + $this->buttons = $this->buttons->reject(function($button) use ($name, $stack) { |
|
98 | 98 | return $stack == null ? $button->name == $name : ($button->stack == $stack) && ($button->name == $name); |
99 | 99 | }); |
100 | 100 | } |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | |
107 | 107 | public function removeAllButtonsFromStack($stack) |
108 | 108 | { |
109 | - $this->buttons = $this->buttons->reject(function ($button) use ($stack) { |
|
109 | + $this->buttons = $this->buttons->reject(function($button) use ($stack) { |
|
110 | 110 | return $button->stack == $stack; |
111 | 111 | }); |
112 | 112 | } |
113 | 113 | |
114 | 114 | public function removeButtonFromStack($name, $stack) |
115 | 115 | { |
116 | - $this->buttons = $this->buttons->reject(function ($button) use ($name, $stack) { |
|
116 | + $this->buttons = $this->buttons->reject(function($button) use ($name, $stack) { |
|
117 | 117 | return $button->name == $name && $button->stack == $stack; |
118 | 118 | }); |
119 | 119 | } |
@@ -59,6 +59,9 @@ discard block |
||
59 | 59 | $this->addButton($stack, $name, 'model_function', $model_function_name, $position); |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $view |
|
64 | + */ |
|
62 | 65 | public function addButtonFromView($stack, $name, $view, $position = false) |
63 | 66 | { |
64 | 67 | $view = 'vendor.backpack.crud.buttons.'.$view; |
@@ -104,6 +107,9 @@ discard block |
||
104 | 107 | $this->buttons = collect([]); |
105 | 108 | } |
106 | 109 | |
110 | + /** |
|
111 | + * @param string $stack |
|
112 | + */ |
|
107 | 113 | public function removeAllButtonsFromStack($stack) |
108 | 114 | { |
109 | 115 | $this->buttons = $this->buttons->reject(function ($button) use ($stack) { |
@@ -126,6 +132,12 @@ discard block |
||
126 | 132 | public $type = 'view'; |
127 | 133 | public $content; |
128 | 134 | |
135 | + /** |
|
136 | + * @param string $stack |
|
137 | + * @param string $name |
|
138 | + * @param string $type |
|
139 | + * @param string $content |
|
140 | + */ |
|
129 | 141 | public function __construct($stack, $name, $type, $content) |
130 | 142 | { |
131 | 143 | $this->stack = $stack; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function hasAccess($permission) |
35 | 35 | { |
36 | - if (! in_array($permission, $this->access)) { |
|
36 | + if (!in_array($permission, $this->access)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function hasAccessToAll($permission_array) |
69 | 69 | { |
70 | 70 | foreach ($permission_array as $key => $permission) { |
71 | - if (! in_array($permission, $this->access)) { |
|
71 | + if (!in_array($permission, $this->access)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function hasAccessOrFail($permission) |
88 | 88 | { |
89 | - if (! in_array($permission, $this->access)) { |
|
89 | + if (!in_array($permission, $this->access)) { |
|
90 | 90 | throw new AccessDeniedException(trans('backpack::crud.unauthorized_access')); |
91 | 91 | } |
92 | 92 |
@@ -12,12 +12,18 @@ |
||
12 | 12 | |-------------------------------------------------------------------------- |
13 | 13 | */ |
14 | 14 | |
15 | + /** |
|
16 | + * @param string $access |
|
17 | + */ |
|
15 | 18 | public function allowAccess($access) |
16 | 19 | { |
17 | 20 | // $this->addButtons((array)$access); |
18 | 21 | return $this->access = array_merge(array_diff((array) $access, $this->access), $this->access); |
19 | 22 | } |
20 | 23 | |
24 | + /** |
|
25 | + * @param string $access |
|
26 | + */ |
|
21 | 27 | public function denyAccess($access) |
22 | 28 | { |
23 | 29 | // $this->removeButtons((array)$access); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * |
16 | 16 | * @param int $id The id of the item to be deleted. |
17 | 17 | * |
18 | - * @return bool True if the item was deleted. |
|
18 | + * @return string True if the item was deleted. |
|
19 | 19 | * |
20 | 20 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException if the model was not found. |
21 | 21 | * |
@@ -123,6 +123,7 @@ |
||
123 | 123 | * |
124 | 124 | * @param [string] Route name. |
125 | 125 | * @param [array] Parameters. |
126 | + * @param string $route |
|
126 | 127 | */ |
127 | 128 | public function setRouteName($route, $parameters = []) |
128 | 129 | { |
@@ -2,27 +2,27 @@ |
||
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; |
17 | +use Backpack\CRUD\PanelTraits\Query; |
|
18 | +use Backpack\CRUD\PanelTraits\Read; |
|
20 | 19 | use Backpack\CRUD\PanelTraits\Reorder; |
21 | -use Backpack\CRUD\PanelTraits\AutoFocus; |
|
22 | -use Backpack\CRUD\PanelTraits\FakeFields; |
|
23 | -use Backpack\CRUD\PanelTraits\FakeColumns; |
|
24 | -use Illuminate\Database\Eloquent\Collection; |
|
20 | +use Backpack\CRUD\PanelTraits\Search; |
|
21 | +use Backpack\CRUD\PanelTraits\Tabs; |
|
22 | +use Backpack\CRUD\PanelTraits\Update; |
|
23 | +use Backpack\CRUD\PanelTraits\Views; |
|
25 | 24 | use Backpack\CRUD\PanelTraits\ViewsAndRestoresRevisions; |
25 | +use Illuminate\Database\Eloquent\Collection; |
|
26 | 26 | |
27 | 27 | class CrudPanel |
28 | 28 | { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function setModel($model_namespace) |
90 | 90 | { |
91 | - if (! class_exists($model_namespace)) { |
|
91 | + if (!class_exists($model_namespace)) { |
|
92 | 92 | throw new \Exception('This model does not exist.', 404); |
93 | 93 | } |
94 | 94 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $complete_route = $route.'.index'; |
140 | 140 | |
141 | - if (! \Route::has($complete_route)) { |
|
141 | + if (!\Route::has($complete_route)) { |
|
142 | 142 | throw new \Exception('There are no routes for this route name.', 404); |
143 | 143 | } |
144 | 144 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function getFirstOfItsTypeInArray($type, $array) |
190 | 190 | { |
191 | - return array_first($array, function ($item) use ($type) { |
|
191 | + return array_first($array, function($item) use ($type) { |
|
192 | 192 | return $item['type'] == $type; |
193 | 193 | }); |
194 | 194 | } |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | |
206 | 206 | public function sync($type, $fields, $attributes) |
207 | 207 | { |
208 | - if (! empty($this->{$type})) { |
|
209 | - $this->{$type} = array_map(function ($field) use ($fields, $attributes) { |
|
208 | + if (!empty($this->{$type})) { |
|
209 | + $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
|
210 | 210 | if (in_array($field['name'], (array) $fields)) { |
211 | 211 | $field = array_merge($field, $attributes); |
212 | 212 | } |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function ($item) use ($items) { |
|
242 | - return ! in_array($item['name'], $this->sort[$items]); |
|
241 | + return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use ($items) { |
|
242 | + return !in_array($item['name'], $this->sort[$items]); |
|
243 | 243 | })); |
244 | 244 | } |
245 | 245 | |
@@ -268,15 +268,15 @@ discard block |
||
268 | 268 | { |
269 | 269 | $relationArray = explode('.', $relationString); |
270 | 270 | |
271 | - if (! isset($length)) { |
|
271 | + if (!isset($length)) { |
|
272 | 272 | $length = count($relationArray); |
273 | 273 | } |
274 | 274 | |
275 | - if (! isset($model)) { |
|
275 | + if (!isset($model)) { |
|
276 | 276 | $model = $this->model; |
277 | 277 | } |
278 | 278 | |
279 | - $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
279 | + $result = array_reduce(array_splice($relationArray, 0, $length), function($obj, $method) { |
|
280 | 280 | return $obj->$method()->getRelated(); |
281 | 281 | }, $model); |
282 | 282 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $relation = $model->{$firstRelationName}; |
324 | 324 | |
325 | 325 | $results = []; |
326 | - if (! empty($relation)) { |
|
326 | + if (!empty($relation)) { |
|
327 | 327 | if ($relation instanceof Collection) { |
328 | 328 | $currentResults = $relation->toArray(); |
329 | 329 | } else { |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | array_shift($relationArray); |
334 | 334 | |
335 | - if (! empty($relationArray)) { |
|
335 | + if (!empty($relationArray)) { |
|
336 | 336 | foreach ($currentResults as $currentResult) { |
337 | 337 | $results = array_merge($results, $this->getRelationModelInstances($currentResult, implode('.', $relationArray))); |
338 | 338 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Move the most recently added column after the given target column. |
96 | 96 | * |
97 | - * @param string|array $targetColumn The target column name or array. |
|
97 | + * @param string $targetColumn The target column name or array. |
|
98 | 98 | */ |
99 | 99 | public function afterColumn($targetColumn) |
100 | 100 | { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Move the most recently added column before the given target column. |
106 | 106 | * |
107 | - * @param string|array $targetColumn The target column name or array. |
|
107 | + * @param string $targetColumn The target column name or array. |
|
108 | 108 | */ |
109 | 109 | public function beforeColumn($targetColumn) |
110 | 110 | { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | public function addColumn($column) |
65 | 65 | { |
66 | 66 | // if a string was passed, not an array, change it to an array |
67 | - if (! is_array($column)) { |
|
67 | + if (!is_array($column)) { |
|
68 | 68 | $column = ['name' => $column]; |
69 | 69 | } |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $column_with_details = $this->addDefaultLabel($column); |
73 | 73 | |
74 | 74 | // make sure the column has a name |
75 | - if (! array_key_exists('name', $column_with_details)) { |
|
75 | + if (!array_key_exists('name', $column_with_details)) { |
|
76 | 76 | $column_with_details['name'] = 'anonymous_column_'.str_random(5); |
77 | 77 | } |
78 | 78 | |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | $columnExistsInDb = $this->hasColumn($this->model->getTable(), $column_with_details['name']); |
81 | 81 | |
82 | 82 | // make sure the column has a type |
83 | - if (! array_key_exists('type', $column_with_details)) { |
|
83 | + if (!array_key_exists('type', $column_with_details)) { |
|
84 | 84 | $column_with_details['type'] = 'text'; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // make sure the column has a key |
88 | - if (! array_key_exists('key', $column_with_details)) { |
|
88 | + if (!array_key_exists('key', $column_with_details)) { |
|
89 | 89 | $column_with_details['key'] = $column_with_details['name']; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // make sure the column has a tableColumn boolean |
93 | - if (! array_key_exists('tableColumn', $column_with_details)) { |
|
93 | + if (!array_key_exists('tableColumn', $column_with_details)) { |
|
94 | 94 | $column_with_details['tableColumn'] = $columnExistsInDb ? true : false; |
95 | 95 | } |
96 | 96 | |
97 | 97 | // make sure the column has a orderable boolean |
98 | - if (! array_key_exists('orderable', $column_with_details)) { |
|
98 | + if (!array_key_exists('orderable', $column_with_details)) { |
|
99 | 99 | $column_with_details['orderable'] = $columnExistsInDb ? true : false; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // make sure the column has a searchLogic |
103 | - if (! array_key_exists('searchLogic', $column_with_details)) { |
|
103 | + if (!array_key_exists('searchLogic', $column_with_details)) { |
|
104 | 104 | $column_with_details['searchLogic'] = $columnExistsInDb ? true : false; |
105 | 105 | } |
106 | 106 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | // if this is a relation type field and no corresponding model was specified, get it from the relation method |
110 | 110 | // defined in the main model |
111 | - if (isset($column_with_details['entity']) && ! isset($column_with_details['model'])) { |
|
111 | + if (isset($column_with_details['entity']) && !isset($column_with_details['model'])) { |
|
112 | 112 | $column_with_details['model'] = $this->getRelationModel($column_with_details['entity']); |
113 | 113 | } |
114 | 114 | |
@@ -162,8 +162,7 @@ discard block |
||
162 | 162 | $targetColumnName = is_array($targetColumn) ? $targetColumn['name'] : $targetColumn; |
163 | 163 | |
164 | 164 | if (array_key_exists($targetColumnName, $this->columns)) { |
165 | - $targetColumnPosition = $before ? array_search($targetColumnName, array_keys($this->columns)) : |
|
166 | - array_search($targetColumnName, array_keys($this->columns)) + 1; |
|
165 | + $targetColumnPosition = $before ? array_search($targetColumnName, array_keys($this->columns)) : array_search($targetColumnName, array_keys($this->columns)) + 1; |
|
167 | 166 | |
168 | 167 | $element = array_pop($this->columns); |
169 | 168 | $beginningPart = array_slice($this->columns, 0, $targetColumnPosition, true); |
@@ -197,7 +196,7 @@ discard block |
||
197 | 196 | */ |
198 | 197 | public function addDefaultLabel($array) |
199 | 198 | { |
200 | - if (! array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) { |
|
199 | + if (!array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) { |
|
201 | 200 | $array = array_merge(['label' => ucfirst($this->makeLabel($array['name']))], $array); |
202 | 201 | |
203 | 202 | return $array; |
@@ -223,7 +222,7 @@ discard block |
||
223 | 222 | */ |
224 | 223 | public function removeColumns($columns) |
225 | 224 | { |
226 | - if (! empty($columns)) { |
|
225 | + if (!empty($columns)) { |
|
227 | 226 | foreach ($columns as $columnName) { |
228 | 227 | $this->removeColumn($columnName); |
229 | 228 | } |
@@ -244,8 +243,8 @@ discard block |
||
244 | 243 | */ |
245 | 244 | public function remove($entity, $fields) |
246 | 245 | { |
247 | - return array_values(array_filter($this->{$entity}, function ($field) use ($fields) { |
|
248 | - return ! in_array($field['name'], (array) $fields); |
|
246 | + return array_values(array_filter($this->{$entity}, function($field) use ($fields) { |
|
247 | + return !in_array($field['name'], (array) $fields); |
|
249 | 248 | })); |
250 | 249 | } |
251 | 250 | |
@@ -290,7 +289,7 @@ discard block |
||
290 | 289 | { |
291 | 290 | $columns = $this->getColumns(); |
292 | 291 | |
293 | - return collect($columns)->pluck('entity')->reject(function ($value, $key) { |
|
292 | + return collect($columns)->pluck('entity')->reject(function($value, $key) { |
|
294 | 293 | return $value == null; |
295 | 294 | })->toArray(); |
296 | 295 | } |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4 | 4 | |
5 | -use Faker\Factory; |
|
6 | -use Backpack\CRUD\Tests\Unit\Models\User; |
|
7 | 5 | use Backpack\CRUD\Tests\Unit\Models\Article; |
6 | +use Backpack\CRUD\Tests\Unit\Models\User; |
|
7 | +use Faker\Factory; |
|
8 | 8 | |
9 | 9 | class CrudPanelCreateTest extends BaseDBCrudPanelTest |
10 | 10 | { |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4 | 4 | |
5 | -use Illuminate\Support\Facades\DB; |
|
6 | 5 | use Backpack\CRUD\Tests\Unit\Models\Article; |
7 | 6 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
7 | +use Illuminate\Support\Facades\DB; |
|
8 | 8 | |
9 | 9 | class CrudPanelDeleteTest extends BaseDBCrudPanelTest |
10 | 10 | { |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\Tests\Unit\CrudPanel; |
4 | 4 | |
5 | -use Illuminate\Support\Collection; |
|
6 | -use Illuminate\Support\Facades\DB; |
|
7 | -use Backpack\CRUD\Tests\Unit\Models\User; |
|
8 | 5 | use Backpack\CRUD\Tests\Unit\Models\Article; |
6 | +use Backpack\CRUD\Tests\Unit\Models\User; |
|
9 | 7 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
8 | +use Illuminate\Support\Collection; |
|
9 | +use Illuminate\Support\Facades\DB; |
|
10 | 10 | |
11 | 11 | class CrudPanelReadTest extends BaseDBCrudPanelTest |
12 | 12 | { |