@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function ($router) { |
|
4 | - if (! $router->has('admin.dashboard')) { |
|
3 | +$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function($router) { |
|
4 | + if (!$router->has('admin.dashboard')) { |
|
5 | 5 | $router->get('', ['as' => 'dashboard', 'uses' => 'AdminController@getDashboard']); |
6 | 6 | } |
7 | 7 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | protected $viewPath; |
13 | 13 | |
14 | 14 | /** |
15 | - * @param string|View $view |
|
15 | + * @param string $view |
|
16 | 16 | * |
17 | 17 | * @return $this |
18 | 18 | */ |
@@ -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 |
@@ -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 | { |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | |
101 | 101 | parent::initialize(); |
102 | 102 | |
103 | - if (! $this->hasHtmlAttribute('enctype')) { |
|
103 | + if (!$this->hasHtmlAttribute('enctype')) { |
|
104 | 104 | // Try to find upload element |
105 | - $this->getElements()->each(function ($element) { |
|
105 | + $this->getElements()->each(function($element) { |
|
106 | 106 | |
107 | 107 | // TODO: this not works withs nested elements |
108 | - if ($element instanceof Upload and ! $this->hasHtmlAttribute('enctype')) { |
|
108 | + if ($element instanceof Upload and !$this->hasHtmlAttribute('enctype')) { |
|
109 | 109 | $this->setHtmlAttribute('enctype', 'multipart/form-data'); |
110 | 110 | } |
111 | 111 | }); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function setItems($items) |
212 | 212 | { |
213 | - if (! is_array($items)) { |
|
213 | + if (!is_array($items)) { |
|
214 | 214 | $items = func_get_args(); |
215 | 215 | } |
216 | 216 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function setId($id) |
239 | 239 | { |
240 | - if (is_null($this->id) and ! is_null($id) and ($model = $this->getRepository()->find($id))) { |
|
240 | + if (is_null($this->id) and !is_null($id) and ($model = $this->getRepository()->find($id))) { |
|
241 | 241 | $this->id = $id; |
242 | 242 | |
243 | 243 | parent::setModel($model); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | */ |
299 | 299 | public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) |
300 | 300 | { |
301 | - if (! $this->validModelConfiguration($modelConfiguration)) { |
|
301 | + if (!$this->validModelConfiguration($modelConfiguration)) { |
|
302 | 302 | return false; |
303 | 303 | } |
304 | 304 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | protected function saveBelongsToRelations(Model $model) |
339 | 339 | { |
340 | 340 | foreach ($model->getRelations() as $name => $relation) { |
341 | - if ($model->{$name}() instanceof BelongsTo && ! is_null($relation)) { |
|
341 | + if ($model->{$name}() instanceof BelongsTo && !is_null($relation)) { |
|
342 | 342 | $relation->save(); |
343 | 343 | $model->{$name}()->associate($relation); |
344 | 344 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | protected function saveHasOneRelations(Model $model) |
354 | 354 | { |
355 | 355 | foreach ($model->getRelations() as $name => $relation) { |
356 | - if ($model->{$name}() instanceof HasOneOrMany && ! is_null($relation)) { |
|
356 | + if ($model->{$name}() instanceof HasOneOrMany && !is_null($relation)) { |
|
357 | 357 | if (is_array($relation) || $relation instanceof \Traversable) { |
358 | 358 | $model->{$name}()->saveMany($relation); |
359 | 359 | } else { |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | */ |
372 | 372 | public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) |
373 | 373 | { |
374 | - if (! $this->validModelConfiguration($modelConfiguration)) { |
|
374 | + if (!$this->validModelConfiguration($modelConfiguration)) { |
|
375 | 375 | return; |
376 | 376 | } |
377 | 377 |
@@ -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); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | |
51 | 51 | $admin->navigation()->setCurrentUrl($request->url()); |
52 | 52 | |
53 | - if (! $this->breadcrumbs->exists('home')) { |
|
54 | - $this->breadcrumbs->register('home', function ($breadcrumbs) { |
|
53 | + if (!$this->breadcrumbs->exists('home')) { |
|
54 | + $this->breadcrumbs->register('home', function($breadcrumbs) { |
|
55 | 55 | $breadcrumbs->push(trans('sleeping_owl::lang.dashboard'), route('admin.dashboard')); |
56 | 56 | }); |
57 | 57 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | foreach ($breadcrumbs as $breadcrumb) { |
75 | - if (! $this->breadcrumbs->exists($breadcrumb['id'])) { |
|
76 | - $this->breadcrumbs->register($breadcrumb['id'], function ($breadcrumbs) use ($breadcrumb) { |
|
75 | + if (!$this->breadcrumbs->exists($breadcrumb['id'])) { |
|
76 | + $this->breadcrumbs->register($breadcrumb['id'], function($breadcrumbs) use ($breadcrumb) { |
|
77 | 77 | $breadcrumbs->parent($breadcrumb['parent']); |
78 | 78 | $breadcrumbs->push($breadcrumb['title'], $breadcrumb['url']); |
79 | 79 | }); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getDisplay(ModelConfigurationInterface $model) |
119 | 119 | { |
120 | - if (! $model->isDisplayable()) { |
|
120 | + if (!$model->isDisplayable()) { |
|
121 | 121 | abort(404); |
122 | 122 | } |
123 | 123 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function getCreate(ModelConfigurationInterface $model) |
135 | 135 | { |
136 | - if (! $model->isCreatable()) { |
|
136 | + if (!$model->isCreatable()) { |
|
137 | 137 | abort(404); |
138 | 138 | } |
139 | 139 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function postStore(ModelConfigurationInterface $model, Request $request) |
154 | 154 | { |
155 | - if (! $model->isCreatable()) { |
|
155 | + if (!$model->isCreatable()) { |
|
156 | 156 | abort(404); |
157 | 157 | } |
158 | 158 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $redirectPolicy = $model->getRedirect(); |
189 | 189 | |
190 | 190 | /* Make redirect when use in model config && Fix editable redirect */ |
191 | - if ($redirectPolicy->get('create') == 'display' || ! $model->isEditable($newModel)) { |
|
191 | + if ($redirectPolicy->get('create') == 'display' || !$model->isEditable($newModel)) { |
|
192 | 192 | $redirectUrl = $model->getDisplayUrl(); |
193 | 193 | } |
194 | 194 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | $item = $model->getRepository()->find($id); |
227 | 227 | |
228 | - if (is_null($item) || ! $model->isEditable($item)) { |
|
228 | + if (is_null($item) || !$model->isEditable($item)) { |
|
229 | 229 | abort(404); |
230 | 230 | } |
231 | 231 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $editForm = $model->fireEdit($id); |
250 | 250 | $item = $editForm->getModel(); |
251 | 251 | |
252 | - if (is_null($item) || ! $model->isEditable($item)) { |
|
252 | + if (is_null($item) || !$model->isEditable($item)) { |
|
253 | 253 | abort(404); |
254 | 254 | } |
255 | 255 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $display = $model->fireDisplay(); |
323 | 323 | |
324 | 324 | /** @var ColumnEditableInterface|null $column */ |
325 | - $column = $display->getColumns()->all()->filter(function ($column) use ($field) { |
|
325 | + $column = $display->getColumns()->all()->filter(function($column) use ($field) { |
|
326 | 326 | return ($column instanceof ColumnEditableInterface) and $field == $column->getName(); |
327 | 327 | })->first(); |
328 | 328 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $repository = $model->getRepository(); |
334 | 334 | $item = $repository->find($id); |
335 | 335 | |
336 | - if (is_null($item) || ! $model->isEditable($item)) { |
|
336 | + if (is_null($item) || !$model->isEditable($item)) { |
|
337 | 337 | abort(404); |
338 | 338 | } |
339 | 339 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | { |
361 | 361 | $item = $model->getRepository()->find($id); |
362 | 362 | |
363 | - if (is_null($item) || ! $model->isDeletable($item)) { |
|
363 | + if (is_null($item) || !$model->isDeletable($item)) { |
|
364 | 364 | abort(404); |
365 | 365 | } |
366 | 366 | |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function deleteDestroy(ModelConfigurationInterface $model, Request $request, $id) |
391 | 391 | { |
392 | - if (! $model->isRestorableModel()) { |
|
392 | + if (!$model->isRestorableModel()) { |
|
393 | 393 | abort(404); |
394 | 394 | } |
395 | 395 | |
396 | 396 | $item = $model->getRepository()->findOnlyTrashed($id); |
397 | 397 | |
398 | - if (is_null($item) || ! $model->isRestorable($item)) { |
|
398 | + if (is_null($item) || !$model->isRestorable($item)) { |
|
399 | 399 | abort(404); |
400 | 400 | } |
401 | 401 | |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function postRestore(ModelConfigurationInterface $model, Request $request, $id) |
426 | 426 | { |
427 | - if (! $model->isRestorableModel()) { |
|
427 | + if (!$model->isRestorableModel()) { |
|
428 | 428 | abort(404); |
429 | 429 | } |
430 | 430 | |
431 | 431 | $item = $model->getRepository()->findOnlyTrashed($id); |
432 | 432 | |
433 | - if (is_null($item) || ! $model->isRestorable($item)) { |
|
433 | + if (is_null($item) || !$model->isRestorable($item)) { |
|
434 | 434 | abort(404); |
435 | 435 | } |
436 | 436 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | */ |
557 | 557 | protected function registerBreadcrumb($title, $parent) |
558 | 558 | { |
559 | - $this->breadcrumbs->register('render', function ($breadcrumbs) use ($title, $parent) { |
|
559 | + $this->breadcrumbs->register('render', function($breadcrumbs) use ($title, $parent) { |
|
560 | 560 | $breadcrumbs->parent($parent); |
561 | 561 | $breadcrumbs->push($title); |
562 | 562 | }); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @param ModelConfigurationInterface $model |
312 | 312 | * @param Request $request |
313 | 313 | * |
314 | - * @return bool |
|
314 | + * @return boolean|null |
|
315 | 315 | * |
316 | 316 | * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
317 | 317 | */ |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | /** |
535 | 535 | * @param Request $request |
536 | 536 | * |
537 | - * @return null|string |
|
537 | + * @return string |
|
538 | 538 | */ |
539 | 539 | protected function getBackUrl(Request $request) |
540 | 540 | { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace SleepingOwl\Admin\Http\Controllers; |
4 | 4 | |
5 | 5 | use Illuminate\Http\Request; |
6 | -use Illuminate\Http\Response; |
|
7 | 6 | use Illuminate\Routing\Controller; |
8 | 7 | use Illuminate\Contracts\Support\Renderable; |
9 | 8 | use Illuminate\Validation\ValidationException; |
@@ -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 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getOptions() |
56 | 56 | { |
57 | - if (! is_null($this->getModelForOptions()) && ! is_null($this->getDisplay())) { |
|
57 | + if (!is_null($this->getModelForOptions()) && !is_null($this->getDisplay())) { |
|
58 | 58 | $this->setOptions( |
59 | 59 | $this->loadOptions() |
60 | 60 | ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function exclude($keys) |
137 | 137 | { |
138 | - if (! is_array($keys)) { |
|
138 | + if (!is_array($keys)) { |
|
139 | 139 | $keys = func_get_args(); |
140 | 140 | } |
141 | 141 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function getValueFromModel() |
51 | 51 | { |
52 | 52 | $value = parent::getValueFromModel(); |
53 | - if (! empty($value)) { |
|
53 | + if (!empty($value)) { |
|
54 | 54 | return $this->parseValue($value); |
55 | 55 | } |
56 | 56 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function setModelAttribute($value) |
84 | 84 | { |
85 | - $value = ! empty($value) |
|
85 | + $value = !empty($value) |
|
86 | 86 | ? Carbon::createFromFormat($this->getPickerFormat(), $value)->format($this->getFormat()) |
87 | 87 | : null; |
88 | 88 |