@@ -112,7 +112,7 @@ |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * @param string|Model $class |
|
115 | + * @param string|null $class |
|
116 | 116 | * @return ModelConfigurationInterface |
117 | 117 | */ |
118 | 118 | public function getModel($class) |
@@ -121,7 +121,7 @@ |
||
121 | 121 | $class = get_class($class); |
122 | 122 | } |
123 | 123 | |
124 | - if (! $this->hasModel($class)) { |
|
124 | + if (!$this->hasModel($class)) { |
|
125 | 125 | $this->registerModel($class); |
126 | 126 | } |
127 | 127 |
@@ -4,13 +4,10 @@ |
||
4 | 4 | |
5 | 5 | use Closure; |
6 | 6 | use Validator; |
7 | -use Illuminate\Http\Request; |
|
8 | 7 | use Illuminate\Routing\Router; |
9 | -use Illuminate\Http\JsonResponse; |
|
10 | 8 | use Illuminate\Http\UploadedFile; |
11 | 9 | use KodiComponents\Support\Upload; |
12 | 10 | use SleepingOwl\Admin\Contracts\WithRoutesInterface; |
13 | -use SleepingOwl\Admin\Contracts\ModelConfigurationInterface; |
|
14 | 11 | |
15 | 12 | class File extends NamedFormElement implements WithRoutesInterface |
16 | 13 | { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | $routeName = 'admin.form.element.'.static::$route; |
28 | 28 | |
29 | - if (! $router->has($routeName)) { |
|
29 | + if (!$router->has($routeName)) { |
|
30 | 30 | $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ |
31 | 31 | 'as' => $routeName, |
32 | 32 | 'uses' => 'SleepingOwl\Admin\Http\Controllers\UploadController@fromField' |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getUploadPath(UploadedFile $file) |
97 | 97 | { |
98 | - if (! is_callable($this->uploadPath)) { |
|
98 | + if (!is_callable($this->uploadPath)) { |
|
99 | 99 | return $this->defaultUploadPath($file); |
100 | 100 | } |
101 | 101 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getUploadFileName(UploadedFile $file) |
123 | 123 | { |
124 | - if (! is_callable($this->uploadFileName)) { |
|
124 | + if (!is_callable($this->uploadFileName)) { |
|
125 | 125 | return $this->defaultUploadFilename($file); |
126 | 126 | } |
127 | 127 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | /** |
72 | 72 | * FormDefault constructor. |
73 | 73 | * |
74 | - * @param array $elements |
|
74 | + * @param Element\Checkbox[] $elements |
|
75 | 75 | */ |
76 | 76 | public function __construct(array $elements = []) |
77 | 77 | { |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @deprecated 4.5.0 |
191 | 191 | * @see getElements() |
192 | 192 | * |
193 | - * @return Collection[] |
|
193 | + * @return FormElementsCollection |
|
194 | 194 | */ |
195 | 195 | public function getItems() |
196 | 196 | { |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | |
100 | 100 | parent::initialize(); |
101 | 101 | |
102 | - if (! $this->hasHtmlAttribute('enctype')) { |
|
102 | + if (!$this->hasHtmlAttribute('enctype')) { |
|
103 | 103 | // Try to find upload element |
104 | - $this->getElements()->each(function ($element) { |
|
104 | + $this->getElements()->each(function($element) { |
|
105 | 105 | |
106 | 106 | // TODO: this not works withs nested elements |
107 | - if ($element instanceof Upload and ! $this->hasHtmlAttribute('enctype')) { |
|
107 | + if ($element instanceof Upload and !$this->hasHtmlAttribute('enctype')) { |
|
108 | 108 | $this->setHtmlAttribute('enctype', 'multipart/form-data'); |
109 | 109 | } |
110 | 110 | }); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function setItems($items) |
209 | 209 | { |
210 | - if (! is_array($items)) { |
|
210 | + if (!is_array($items)) { |
|
211 | 211 | $items = func_get_args(); |
212 | 212 | } |
213 | 213 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function setId($id) |
236 | 236 | { |
237 | - if (is_null($this->id) and ! is_null($id) and ($model = $this->getRepository()->find($id))) { |
|
237 | + if (is_null($this->id) and !is_null($id) and ($model = $this->getRepository()->find($id))) { |
|
238 | 238 | $this->id = $id; |
239 | 239 | |
240 | 240 | $this->setModel($model); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) |
303 | 303 | { |
304 | - if (! $this->validModelConfiguration($modelConfiguration)) { |
|
304 | + if (!$this->validModelConfiguration($modelConfiguration)) { |
|
305 | 305 | return false; |
306 | 306 | } |
307 | 307 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | protected function saveBelongsToRelations(Model $model) |
342 | 342 | { |
343 | 343 | foreach ($model->getRelations() as $name => $relation) { |
344 | - if ($model->{$name}() instanceof BelongsTo && ! is_null($relation)) { |
|
344 | + if ($model->{$name}() instanceof BelongsTo && !is_null($relation)) { |
|
345 | 345 | $relation->save(); |
346 | 346 | $model->{$name}()->associate($relation); |
347 | 347 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | protected function saveHasOneRelations(Model $model) |
357 | 357 | { |
358 | 358 | foreach ($model->getRelations() as $name => $relation) { |
359 | - if ($model->{$name}() instanceof HasOneOrMany && ! is_null($relation)) { |
|
359 | + if ($model->{$name}() instanceof HasOneOrMany && !is_null($relation)) { |
|
360 | 360 | if (is_array($relation) || $relation instanceof \Traversable) { |
361 | 361 | $model->{$name}()->saveMany($relation); |
362 | 362 | } else { |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) |
376 | 376 | { |
377 | - if (! $this->validModelConfiguration($modelConfiguration)) { |
|
377 | + if (!$this->validModelConfiguration($modelConfiguration)) { |
|
378 | 378 | return; |
379 | 379 | } |
380 | 380 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function dependentSelect(Request $request, ModelConfigurationInterface $model, $field, $id = null) |
22 | 22 | { |
23 | - if (! is_null($id)) { |
|
23 | + if (!is_null($id)) { |
|
24 | 24 | $item = $model->getRepository()->find($id); |
25 | - if (is_null($item) || ! $model->isEditable($item)) { |
|
25 | + if (is_null($item) || !$model->isEditable($item)) { |
|
26 | 26 | return new JsonResponse([ |
27 | 27 | 'message' => trans('lang.message.access_denied'), |
28 | 28 | ], 403); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $form = $model->fireEdit($id); |
32 | 32 | } else { |
33 | - if (! $model->isCreatable()) { |
|
33 | + if (!$model->isCreatable()) { |
|
34 | 34 | return new JsonResponse([ |
35 | 35 | 'message' => trans('lang.message.access_denied'), |
36 | 36 | ], 403); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | } |
58 | 58 | |
59 | 59 | return new JsonResponse([ |
60 | - 'output' => collect($options)->map(function ($value, $key) { |
|
60 | + 'output' => collect($options)->map(function($value, $key) { |
|
61 | 61 | return ['id' => $key, 'name' => $value]; |
62 | 62 | }), |
63 | 63 | 'selected' => $element->getValueFromModel(), |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function fromField(Request $request, ModelConfigurationInterface $model, $field, $id = null) |
24 | 24 | { |
25 | - if (! is_null($id)) { |
|
25 | + if (!is_null($id)) { |
|
26 | 26 | $item = $model->getRepository()->find($id); |
27 | - if (is_null($item) || ! $model->isEditable($item)) { |
|
27 | + if (is_null($item) || !$model->isEditable($item)) { |
|
28 | 28 | return new JsonResponse([ |
29 | 29 | 'message' => trans('lang.message.access_denied'), |
30 | 30 | ], 403); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $form = $model->fireEdit($id); |
34 | 34 | } else { |
35 | - if (! $model->isCreatable()) { |
|
35 | + if (!$model->isCreatable()) { |
|
36 | 36 | return new JsonResponse([ |
37 | 37 | 'message' => trans('lang.message.access_denied'), |
38 | 38 | ], 403); |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $display = $model->fireDisplay(); |
60 | 60 | |
61 | 61 | if ($display instanceof DisplayTabbed) { |
62 | - $display->getTabs()->each(function ($tab) use($request) { |
|
62 | + $display->getTabs()->each(function($tab) use($request) { |
|
63 | 63 | $content = $tab->getContent(); |
64 | 64 | if ($content instanceof DisplayTree) { |
65 | 65 | $content->getRepository()->reorder( |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function aliases() |
14 | 14 | { |
15 | - return $this->map(function (ModelConfigurationInterface $model) { |
|
15 | + return $this->map(function(ModelConfigurationInterface $model) { |
|
16 | 16 | return $model->getAlias(); |
17 | 17 | }); |
18 | 18 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function keyByAlias() |
24 | 24 | { |
25 | - return $this->keyBy(function (ModelConfigurationInterface $model) { |
|
25 | + return $this->keyBy(function(ModelConfigurationInterface $model) { |
|
26 | 26 | return $model->getAlias(); |
27 | 27 | }); |
28 | 28 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function isCreatable() |
202 | 202 | { |
203 | - if (! is_callable($this->getCreate())) { |
|
203 | + if (!is_callable($this->getCreate())) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function isEditable(Model $model) |
226 | 226 | { |
227 | - if (! is_callable($this->getEdit())) { |
|
227 | + if (!is_callable($this->getEdit())) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function fireDisplay() |
348 | 348 | { |
349 | - if (! is_callable($this->getDisplay())) { |
|
349 | + if (!is_callable($this->getDisplay())) { |
|
350 | 350 | return; |
351 | 351 | } |
352 | 352 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function fireCreate() |
389 | 389 | { |
390 | - if (! is_callable($this->getCreate())) { |
|
390 | + if (!is_callable($this->getCreate())) { |
|
391 | 391 | return; |
392 | 392 | } |
393 | 393 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function fireEdit($id) |
436 | 436 | { |
437 | - if (! is_callable($this->getEdit())) { |
|
437 | + if (!is_callable($this->getEdit())) { |
|
438 | 438 | return; |
439 | 439 | } |
440 | 440 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | $routeName = 'admin.form.element.dependent-select'; |
19 | 19 | |
20 | - if (! $router->has($routeName)) { |
|
20 | + if (!$router->has($routeName)) { |
|
21 | 21 | $router->post('{adminModel}/dependent-select/{field}/{id?}', [ |
22 | 22 | 'as' => $routeName, |
23 | 23 | 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@dependentSelect' |