From fea011f1a2fa95dbc3329b52c913c47d29f2796e Mon Sep 17 00:00:00 2001 From: Aios Date: Tue, 22 May 2018 00:55:04 +0300 Subject: [PATCH 001/108] Scrutinizer Recomends --- composer.json | 2 +- src/Admin.php | 2 +- src/AliasBinder.php | 2 +- src/Console/Commands/InstallCommand.php | 8 ++-- src/Console/Commands/UserManagerCommand.php | 4 +- src/Console/Generator.php | 6 +-- src/Console/Installation/Command.php | 8 ++-- src/Display/Column/Control.php | 26 ++++++------ src/Display/Column/Custom.php | 4 +- src/Display/Column/Editable/DateTime.php | 8 ++-- .../Column/Editable/EditableColumn.php | 2 +- .../Column/Filter/BaseColumnFilter.php | 2 +- src/Display/Column/Filter/Range.php | 6 +-- src/Display/Column/Filter/Select.php | 6 +-- src/Display/Column/Image.php | 2 +- src/Display/Column/NamedColumn.php | 8 ++-- src/Display/Column/Order.php | 6 +-- src/Display/Display.php | 6 +-- src/Display/DisplayDatatables.php | 2 +- src/Display/DisplayDatatablesAsync.php | 8 ++-- src/Display/DisplayTab.php | 6 +-- src/Display/DisplayTabbed.php | 12 +++--- src/Display/DisplayTable.php | 6 +-- src/Display/DisplayTabsCollection.php | 6 +-- src/Display/DisplayTree.php | 10 ++--- src/Display/Extension/Actions.php | 6 +-- src/Display/Extension/Apply.php | 2 +- src/Display/Extension/ColumnFilters.php | 8 ++-- src/Display/Extension/Columns.php | 12 +++--- src/Display/Extension/ColumnsTotal.php | 4 +- src/Display/Extension/Filters.php | 8 ++-- src/Display/Extension/Scopes.php | 4 +- src/Display/ExtensionCollection.php | 10 ++--- src/Display/Filter/FilterBase.php | 6 +-- src/Display/Filter/FilterCustom.php | 2 +- src/Display/Filter/FilterField.php | 4 +- src/Display/Filter/FilterRelated.php | 2 +- src/Display/TableColumn.php | 6 +-- src/Form/Buttons/Delete.php | 2 +- src/Form/Buttons/Destroy.php | 2 +- src/Form/Buttons/Restore.php | 2 +- src/Form/Columns/Columns.php | 12 +++--- src/Form/Element/Custom.php | 2 +- src/Form/Element/DateRange.php | 6 +-- src/Form/Element/DateTime.php | 4 +- src/Form/Element/DependentSelect.php | 2 +- src/Form/Element/File.php | 6 +-- src/Form/Element/Image.php | 4 +- src/Form/Element/Images.php | 6 +-- src/Form/Element/MultiSelect.php | 6 +-- src/Form/Element/MultiSelectAjax.php | 12 +++--- src/Form/Element/NamedFormElement.php | 14 +++---- src/Form/Element/Password.php | 10 ++--- src/Form/Element/SelectAjax.php | 4 +- src/Form/Element/Upload.php | 2 +- src/Form/Element/View.php | 2 +- src/Form/Element/Wysiwyg.php | 8 ++-- src/Form/FormButtons.php | 8 ++-- src/Form/FormDefault.php | 18 ++++---- src/Form/FormElement.php | 2 +- src/Form/FormElementsCollection.php | 6 +-- src/Form/FormPanel.php | 8 ++-- src/Http/Controllers/AdminController.php | 42 +++++++++---------- src/Http/Controllers/DisplayController.php | 2 +- .../Controllers/FormElementController.php | 10 ++--- src/Http/Controllers/UploadController.php | 6 +-- src/Http/routes.php | 4 +- src/Model/ModelCollection.php | 4 +- src/Model/ModelConfiguration.php | 12 +++--- src/Model/ModelConfigurationManager.php | 10 ++--- src/Model/SectionModelConfiguration.php | 6 +-- src/Navigation.php | 8 ++-- src/Navigation/Badge.php | 2 +- src/Navigation/Page.php | 12 +++--- src/Providers/AdminServiceProvider.php | 36 ++++++++-------- src/Providers/BreadcrumbsServiceProvider.php | 2 +- src/Providers/SleepingOwlServiceProvider.php | 8 ++-- src/Repositories/BaseRepository.php | 4 +- src/Repositories/TreeRepository.php | 4 +- src/Routing/ModelRouter.php | 4 +- src/Templates/Assets.php | 8 ++-- src/Templates/Breadcrumbs.php | 4 +- src/Traits/FormElements.php | 16 +++---- src/Traits/OrderableModel.php | 10 ++--- src/Traits/SelectOptionsFromModel.php | 10 ++--- src/Traits/SqlQueryOperators.php | 6 +-- src/Widgets/WidgetsRegistry.php | 10 ++--- src/Wysiwyg/Manager.php | 6 +-- 88 files changed, 313 insertions(+), 313 deletions(-) diff --git a/composer.json b/composer.json index 077f293d7..154b06dd0 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "laravelrus/sleepingowl", "description": "Administrative interface builder for Laravel.", - "homepage": "http://sleepingowl.ru", + "homepage": "http://sleepingowladmin.ru", "keywords": [ "laravel", "admin", diff --git a/src/Admin.php b/src/Admin.php index b713c2ec1..689657bc1 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -164,7 +164,7 @@ public function getModel($class) $class = get_class($class); } - if (! $this->hasModel($class)) { + if (!$this->hasModel($class)) { $this->registerModel($class); } diff --git a/src/AliasBinder.php b/src/AliasBinder.php index 1c1fe7af9..a4ded9e9b 100644 --- a/src/AliasBinder.php +++ b/src/AliasBinder.php @@ -146,7 +146,7 @@ public function makeClass($alias, array $arguments) */ public function __call($name, $arguments) { - if (! $this->hasAlias($name)) { + if (!$this->hasAlias($name)) { throw new BadMethodCallException($name); } diff --git a/src/Console/Commands/InstallCommand.php b/src/Console/Commands/InstallCommand.php index 756e234fd..f77676e56 100644 --- a/src/Console/Commands/InstallCommand.php +++ b/src/Console/Commands/InstallCommand.php @@ -31,11 +31,11 @@ protected function runInstaller() Installation\CreateRoutesFile::class, Installation\CreateSectionServiceProvider::class, Installation\CreatePublicDirectory::class, - ])->map(function ($installer) { + ])->map(function($installer) { return new $installer($this, $this->config); - })->filter(function (Installator $installer) { - return $this->option('force') ? true : ! $installer->installed(); - })->each(function (Installator $installer) { + })->filter(function(Installator $installer) { + return $this->option('force') ? true : !$installer->installed(); + })->each(function(Installator $installer) { $installer->install(); $installer->showInfo(); }); diff --git a/src/Console/Commands/UserManagerCommand.php b/src/Console/Commands/UserManagerCommand.php index 52d64cf78..1d974d84b 100644 --- a/src/Console/Commands/UserManagerCommand.php +++ b/src/Console/Commands/UserManagerCommand.php @@ -86,7 +86,7 @@ protected function createNewUser() return; } - if (! is_null($userClass::where('email', $email)->first())) { + if (!is_null($userClass::where('email', $email)->first())) { $this->error("User with same email [{$email}] exists."); return; @@ -140,7 +140,7 @@ protected function deleteUser() } $confirm = $this->confirm("Are you sure want to delete user with id [{$id}]?", false); - if (! $confirm) { + if (!$confirm) { return; } diff --git a/src/Console/Generator.php b/src/Console/Generator.php index 1a65a0c52..26c4221f1 100644 --- a/src/Console/Generator.php +++ b/src/Console/Generator.php @@ -24,8 +24,8 @@ protected function getAliasesByExtendsNamespace() { $aliases = $this->getValidAliases(); - $aliases = $aliases->filter(function (Alias $item) { - return ! collect([ + $aliases = $aliases->filter(function(Alias $item) { + return !collect([ 'MessageStack', 'AdminSection', 'AdminTemplate', @@ -40,7 +40,7 @@ protected function getAliasesByExtendsNamespace() ])->search($item->getAlias()); }); - return $aliases->groupBy(function (Alias $alias) { + return $aliases->groupBy(function(Alias $alias) { return $alias->getExtendsNamespace(); }); } diff --git a/src/Console/Installation/Command.php b/src/Console/Installation/Command.php index 8649d07b1..937425009 100644 --- a/src/Console/Installation/Command.php +++ b/src/Console/Installation/Command.php @@ -29,11 +29,11 @@ abstract class Command extends ConsoleCommand */ public function fire(Filesystem $files) { - if (! defined('SLEEPINGOWL_STUB_PATH')) { + if (!defined('SLEEPINGOWL_STUB_PATH')) { define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); } - if (! $this->confirmToProceed('SleepingOwl Admin')) { + if (!$this->confirmToProceed('SleepingOwl Admin')) { return; } @@ -55,11 +55,11 @@ public function fire(Filesystem $files) */ public function handle(Filesystem $files) { - if (! defined('SLEEPINGOWL_STUB_PATH')) { + if (!defined('SLEEPINGOWL_STUB_PATH')) { define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); } - if (! $this->confirmToProceed('SleepingOwl Admin')) { + if (!$this->confirmToProceed('SleepingOwl Admin')) { return; } diff --git a/src/Display/Column/Control.php b/src/Display/Column/Control.php index 9480da8f8..834f7ffa0 100644 --- a/src/Display/Column/Control.php +++ b/src/Display/Column/Control.php @@ -64,20 +64,20 @@ public function initialize() { parent::initialize(); - $this->buttons->put('edit', $button = new ControlLink(function (Model $model) { + $this->buttons->put('edit', $button = new ControlLink(function(Model $model) { return $this->getModelConfiguration()->getEditUrl($model->getKey()); }, trans('sleeping_owl::lang.table.edit'), 100)); $button->hideText(); - $button->setCondition(function () { + $button->setCondition(function() { return $this->isEditable(); }); $button->setIcon('fa fa-pencil'); $button->setHtmlAttribute('class', 'btn-primary'); - $this->buttons->put('delete', $button = new ControlButton(function (Model $model) { + $this->buttons->put('delete', $button = new ControlButton(function(Model $model) { return $this->getModelConfiguration()->getDeleteUrl($model->getKey()); }, trans('sleeping_owl::lang.table.delete'), 200)); - $button->setCondition(function () { + $button->setCondition(function() { return $this->isDeletable(); }); @@ -86,10 +86,10 @@ public function initialize() $button->setIcon('fa fa-trash'); $button->setHtmlAttribute('class', 'btn-danger btn-delete'); - $this->buttons->put('destroy', $button = new ControlButton(function (Model $model) { + $this->buttons->put('destroy', $button = new ControlButton(function(Model $model) { return $this->getModelConfiguration()->getDestroyUrl($model->getKey()); }, trans('sleeping_owl::lang.table.destroy'), 300)); - $button->setCondition(function () { + $button->setCondition(function() { return $this->isDestroyable(); }); @@ -98,10 +98,10 @@ public function initialize() $button->setIcon('fa fa-trash'); $button->setHtmlAttribute('class', 'btn-danger btn-destroy'); - $this->buttons->put('restore', $button = new ControlButton(function (Model $model) { + $this->buttons->put('restore', $button = new ControlButton(function(Model $model) { return $this->getModelConfiguration()->getRestoreUrl($model->getKey()); }, trans('sleeping_owl::lang.table.restore'), 400)); - $button->setCondition(function () { + $button->setCondition(function() { return $this->isRestorable(); }); $button->hideText(); @@ -205,7 +205,7 @@ protected function isEditable() return $this->editable && - ! $this->isTrashed() + !$this->isTrashed() && $this->getModelConfiguration()->isEditable( $this->getModel() @@ -222,7 +222,7 @@ protected function isDeletable() return $this->deletable && - ! $this->isTrashed() + !$this->isTrashed() && $this->getModelConfiguration()->isDeletable( $this->getModel() @@ -282,13 +282,13 @@ public function toArray() { return parent::toArray() + [ 'buttons' => $this->buttons - ->each(function (ControlButtonInterface $button) { + ->each(function(ControlButtonInterface $button) { $button->setModel($this->getModel()); }) - ->filter(function (ControlButtonInterface $button) { + ->filter(function(ControlButtonInterface $button) { return $button->isActive(); }) - ->sortBy(function (ControlButtonInterface $button) { + ->sortBy(function(ControlButtonInterface $button) { return $button->getPosition(); }), ]; diff --git a/src/Display/Column/Custom.php b/src/Display/Column/Custom.php index 6835dcf95..eee9f75c9 100644 --- a/src/Display/Column/Custom.php +++ b/src/Display/Column/Custom.php @@ -32,7 +32,7 @@ class Custom extends TableColumn public function __construct($label = null, Closure $callback = null) { parent::__construct($label); - if (! is_null($callback)) { + if (!is_null($callback)) { $this->setCallback($callback); } } @@ -66,7 +66,7 @@ public function setCallback(Closure $callback) */ public function getModelValue() { - if (! is_callable($callback = $this->getCallback())) { + if (!is_callable($callback = $this->getCallback())) { throw new \Exception('Invalid custom column callback'); } diff --git a/src/Display/Column/Editable/DateTime.php b/src/Display/Column/Editable/DateTime.php index 4eec46c1e..7e13a677e 100644 --- a/src/Display/Column/Editable/DateTime.php +++ b/src/Display/Column/Editable/DateTime.php @@ -76,8 +76,8 @@ public function toArray() */ protected function getFormatedDate($date) { - if (! is_null($date)) { - if (! $date instanceof Carbon) { + if (!is_null($date)) { + if (!$date instanceof Carbon) { $date = Carbon::parse($date); } @@ -93,7 +93,7 @@ protected function getFormatedDate($date) public function getValueFromModel() { $value = parent::getValueFromModel(); - if (! empty($value)) { + if (!empty($value)) { return $this->parseValue($value); } } @@ -125,7 +125,7 @@ public function setSeconds($seconds) */ public function setModelAttribute($value) { - $value = ! empty($value) + $value = !empty($value) ? Carbon::createFromFormat($this->getPickerFormat(), $value, $this->getTimezone()) ->timezone(config('app.timezone'))->format($this->getFormat()) : null; diff --git a/src/Display/Column/Editable/EditableColumn.php b/src/Display/Column/Editable/EditableColumn.php index 827dcafd9..fe93b3802 100644 --- a/src/Display/Column/Editable/EditableColumn.php +++ b/src/Display/Column/Editable/EditableColumn.php @@ -70,7 +70,7 @@ public function setTitle($title) */ public function getUrl() { - if (! $this->url) { + if (!$this->url) { return request()->url(); } diff --git a/src/Display/Column/Filter/BaseColumnFilter.php b/src/Display/Column/Filter/BaseColumnFilter.php index 16bad2c1c..279e7f833 100644 --- a/src/Display/Column/Filter/BaseColumnFilter.php +++ b/src/Display/Column/Filter/BaseColumnFilter.php @@ -135,7 +135,7 @@ public function apply(ColumnInterface $column, Builder $query, $queryString, $qu $fieldName = array_pop($parts); $relationName = implode('.', $parts); - $query->whereHas($relationName, function ($q) use ($queryString, $fieldName) { + $query->whereHas($relationName, function($q) use ($queryString, $fieldName) { $this->buildQuery($q, $fieldName, $queryString); }); } else { diff --git a/src/Display/Column/Filter/Range.php b/src/Display/Column/Filter/Range.php index d2c165a61..ec9074ef4 100644 --- a/src/Display/Column/Filter/Range.php +++ b/src/Display/Column/Filter/Range.php @@ -104,15 +104,15 @@ public function parseValue($range) $from = $this->from->parseValue($from); $to = $this->to->parseValue($to); - if (! empty($from) && ! empty($to)) { + if (!empty($from) && !empty($to)) { $this->setOperator('between'); return [$from, $to]; - } elseif (! empty($from)) { + } elseif (!empty($from)) { $this->setOperator('greater_or_equal'); return $from; - } elseif (! empty($to)) { + } elseif (!empty($to)) { $this->setOperator('less_or_equal'); return $to; diff --git a/src/Display/Column/Filter/Select.php b/src/Display/Column/Filter/Select.php index 890061396..efc94425a 100644 --- a/src/Display/Column/Filter/Select.php +++ b/src/Display/Column/Filter/Select.php @@ -52,7 +52,7 @@ public function __construct($options = null, $title = null) $this->setModelForOptions($options); } - if (! is_null($title)) { + if (!is_null($title)) { $this->setDisplay($title); } } @@ -77,7 +77,7 @@ public function initialize() if ($this->multiple) { $this->setHtmlAttribute('multiple', 'multiple'); - if (! in_array($this->operator, ['in', 'not_in'])) { + if (!in_array($this->operator, ['in', 'not_in'])) { $this->setOperator('in'); } } else { @@ -121,7 +121,7 @@ public function setModel($model) */ public function getOptions() { - if (! is_null($this->getModelForOptions()) && ! is_null($this->getDisplay())) { + if (!is_null($this->getModelForOptions()) && !is_null($this->getDisplay())) { $this->setOptions( $this->loadOptions() ); diff --git a/src/Display/Column/Image.php b/src/Display/Column/Image.php index 252141f64..bb29483af 100644 --- a/src/Display/Column/Image.php +++ b/src/Display/Column/Image.php @@ -40,7 +40,7 @@ public function setImageWidth($width) public function toArray() { $value = $this->getModelValue(); - if (! empty($value) && (strpos($value, '://') === false)) { + if (!empty($value) && (strpos($value, '://') === false)) { $value = asset($value); } diff --git a/src/Display/Column/NamedColumn.php b/src/Display/Column/NamedColumn.php index 7b51720e2..6599d2f5f 100644 --- a/src/Display/Column/NamedColumn.php +++ b/src/Display/Column/NamedColumn.php @@ -104,8 +104,8 @@ public function getModelSmallValue() */ public function setOrderable($orderable = true) { - if ($orderable !== false && ! $orderable instanceof OrderByClauseInterface) { - if (! is_string($orderable) && ! $orderable instanceof Closure) { + if ($orderable !== false && !$orderable instanceof OrderByClauseInterface) { + if (!is_string($orderable) && !$orderable instanceof Closure) { $orderable = $this->getName(); } } @@ -173,11 +173,11 @@ protected function getValueFromObject($instance, $name) if ($instance === null) { $instance = collect(); } - } elseif (! is_null($instance)) { + } elseif (!is_null($instance)) { $instance = $instance->getAttribute($part); } - if (! empty($parts) && ! is_null($instance)) { + if (!empty($parts) && !is_null($instance)) { return $this->getValueFromObject($instance, implode('.', $parts)); } diff --git a/src/Display/Column/Order.php b/src/Display/Column/Order.php index 58e8537c3..1e3636b8f 100644 --- a/src/Display/Column/Order.php +++ b/src/Display/Column/Order.php @@ -28,7 +28,7 @@ class Order extends TableColumn implements WithRoutesInterface public static function registerRoutes(Router $router) { $routeName = 'admin.display.column.move-up'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/{adminModelId}/up', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayColumnController@orderUp', @@ -36,7 +36,7 @@ public static function registerRoutes(Router $router) } $routeName = 'admin.display.column.move-down'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/{adminModelId}/down', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayColumnController@orderDown', @@ -56,7 +56,7 @@ public function __construct() */ public function getModel() { - if (! in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { + if (!in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { throw new \Exception("Model [$class] should uses trait [SleepingOwl\\Admin\\Traits\\OrderableModel]"); } diff --git a/src/Display/Display.php b/src/Display/Display.php index 8d4b20cb0..611392c31 100644 --- a/src/Display/Display.php +++ b/src/Display/Display.php @@ -192,7 +192,7 @@ public function getTitle() $this->title, ]; - $this->getExtensions()->each(function (DisplayExtensionInterface $extension) use (&$titles) { + $this->getExtensions()->each(function(DisplayExtensionInterface $extension) use (&$titles) { if (method_exists($extension, $method = 'getTitle')) { $titles[] = call_user_func([$extension, $method]); } @@ -240,7 +240,7 @@ public function render() foreach ($blocks as $block => $data) { foreach ($data as $html) { - if (! empty($html)) { + if (!empty($html)) { $view->getFactory()->startSection($block); echo $html; $view->getFactory()->yieldSection(); @@ -291,7 +291,7 @@ protected function getModelConfiguration() protected function makeRepository() { $repository = app($this->repositoryClass); - if (! ($repository instanceof RepositoryInterface)) { + if (!($repository instanceof RepositoryInterface)) { throw new \Exception('Repository class must be instanced of [RepositoryInterface]'); } diff --git a/src/Display/DisplayDatatables.php b/src/Display/DisplayDatatables.php index 0774dee2d..9708bfd87 100644 --- a/src/Display/DisplayDatatables.php +++ b/src/Display/DisplayDatatables.php @@ -88,7 +88,7 @@ public function getOrder() */ public function setOrder($order) { - if (! is_array($order)) { + if (!is_array($order)) { $order = func_get_args(); } diff --git a/src/Display/DisplayDatatablesAsync.php b/src/Display/DisplayDatatablesAsync.php index 751f30b7d..6cb68e42a 100644 --- a/src/Display/DisplayDatatablesAsync.php +++ b/src/Display/DisplayDatatablesAsync.php @@ -26,7 +26,7 @@ class DisplayDatatablesAsync extends DisplayDatatables implements WithRoutesInte public static function registerRoutes(Router $router) { $routeName = 'admin.display.async'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->get('{adminModel}/async/{adminDisplayName?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayController@async', @@ -34,7 +34,7 @@ public static function registerRoutes(Router $router) } $routeName = 'admin.display.async.inlineEdit'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/async/{adminDisplayName?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\AdminController@inlineEdit', @@ -203,7 +203,7 @@ public function renderAsync(\Illuminate\Http\Request $request) $totalCount = $query->count(); $filteredCount = 0; - if (! is_null($this->distinct)) { + if (!is_null($this->distinct)) { $filteredCount = $query->distinct()->count($this->getDistinct()); } @@ -270,7 +270,7 @@ protected function applySearch(Builder $query, \Illuminate\Http\Request $request return; } - $query->where(function (Builder $query) use ($search) { + $query->where(function(Builder $query) use ($search) { $columns = $this->getColumns()->all(); foreach ($columns as $column) { diff --git a/src/Display/DisplayTab.php b/src/Display/DisplayTab.php index 91d75844a..2c0b2e29b 100644 --- a/src/Display/DisplayTab.php +++ b/src/Display/DisplayTab.php @@ -75,15 +75,15 @@ public function __construct(Renderable $content, $label = null, $icon = null, $b { $this->content = $content; - if (! is_null($label)) { + if (!is_null($label)) { $this->setLabel($label); } - if (! is_null($icon)) { + if (!is_null($icon)) { $this->setIcon($icon); } - if (! is_null($badge)) { + if (!is_null($badge)) { $this->setBadge($badge); } diff --git a/src/Display/DisplayTabbed.php b/src/Display/DisplayTabbed.php index e4f191a82..552c860a1 100644 --- a/src/Display/DisplayTabbed.php +++ b/src/Display/DisplayTabbed.php @@ -67,7 +67,7 @@ public function initialize() } } - $activeTabs = $this->getTabs()->filter(function (TabInterface $tab) { + $activeTabs = $this->getTabs()->filter(function(TabInterface $tab) { return $tab->isActive(); })->count(); @@ -95,7 +95,7 @@ public function getModel() */ public function setModelClass($class) { - $this->getTabs()->each(function (TabInterface $tab) use ($class) { + $this->getTabs()->each(function(TabInterface $tab) use ($class) { if ($tab instanceof DisplayInterface) { $tab->setModelClass($class); } @@ -179,7 +179,7 @@ public function addElement(TabInterface $element) */ public function setAction($action) { - $this->getTabs()->each(function (TabInterface $tab) use ($action) { + $this->getTabs()->each(function(TabInterface $tab) use ($action) { if ($tab instanceof FormInterface) { $tab->setAction($action); } @@ -195,7 +195,7 @@ public function setAction($action) */ public function setId($id) { - $this->getTabs()->each(function (TabInterface $tab) use ($id) { + $this->getTabs()->each(function(TabInterface $tab) use ($id) { if ($tab instanceof FormInterface) { $tab->setId($id); } @@ -212,7 +212,7 @@ public function setId($id) */ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $model = null) { - $this->getTabs()->each(function ($tab) use ($request, $model) { + $this->getTabs()->each(function($tab) use ($request, $model) { $tabId = $request->get('sleeping_owl_tab_id'); if ($tab instanceof FormInterface && $tab->getName() == $tabId) { @@ -229,7 +229,7 @@ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurati */ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $model = null) { - $this->getTabs()->each(function (TabInterface $tab) use ($request, $model) { + $this->getTabs()->each(function(TabInterface $tab) use ($request, $model) { $tabId = $request->get('sleeping_owl_tab_id'); if ($tab instanceof FormInterface && $tab->getName() == $tabId) { diff --git a/src/Display/DisplayTable.php b/src/Display/DisplayTable.php index 28d1cb463..18bb2bbd8 100644 --- a/src/Display/DisplayTable.php +++ b/src/Display/DisplayTable.php @@ -73,7 +73,7 @@ public function initialize() parent::initialize(); if ($this->getModelConfiguration()->isRestorableModel()) { - $this->setApply(function (Builder $q) { + $this->setApply(function(Builder $q) { return $q->withTrashed(); }); } @@ -195,11 +195,11 @@ public function toArray() */ public function getCollection() { - if (! $this->isInitialized()) { + if (!$this->isInitialized()) { throw new \Exception('Display is not initialized'); } - if (! is_null($this->collection)) { + if (!is_null($this->collection)) { return $this->collection; } diff --git a/src/Display/DisplayTabsCollection.php b/src/Display/DisplayTabsCollection.php index c27057deb..56ce4a3bf 100644 --- a/src/Display/DisplayTabsCollection.php +++ b/src/Display/DisplayTabsCollection.php @@ -13,11 +13,11 @@ class DisplayTabsCollection extends FormElementsCollection */ public function onlyActive() { - return $this->filter(function (TabInterface $tab) { + return $this->filter(function(TabInterface $tab) { $element = $tab->getContent(); if ($element instanceof FormElementInterface) { - return ! $element->isReadonly(); + return !$element->isReadonly(); } return true; @@ -29,7 +29,7 @@ public function onlyActive() */ public function onlyVisible() { - return $this->filter(function (TabInterface $tab) { + return $this->filter(function(TabInterface $tab) { return $tab->isVisible(); }); } diff --git a/src/Display/DisplayTree.php b/src/Display/DisplayTree.php index 8273a1e9a..2083447f6 100644 --- a/src/Display/DisplayTree.php +++ b/src/Display/DisplayTree.php @@ -23,7 +23,7 @@ class DisplayTree extends Display implements WithRoutesInterface public static function registerRoutes(Router $router) { $routeName = 'admin.display.tree.reorder'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/reorder', ['as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayController@treeReorder']); } @@ -116,7 +116,7 @@ public function initialize() if ($this->getParentField()) { $repository = $repository->setParentField($this->getParentField()); } - if (! is_null($this->treeType)) { + if (!is_null($this->treeType)) { $repository->setTreeType($this->treeType); } @@ -338,11 +338,11 @@ protected function getModelConfiguration() */ public function getCollection() { - if (! $this->isInitialized()) { + if (!$this->isInitialized()) { throw new \Exception('Display is not initialized'); } - if (! is_null($this->collection)) { + if (!is_null($this->collection)) { return $this->collection; } @@ -373,7 +373,7 @@ protected function makeRepository() { $repository = parent::makeRepository(); - if (! ($repository instanceof TreeRepositoryInterface)) { + if (!($repository instanceof TreeRepositoryInterface)) { throw new \Exception('Repository class must be instanced of [TreeRepositoryInterface]'); } diff --git a/src/Display/Extension/Actions.php b/src/Display/Extension/Actions.php index 26e67e3ec..fc303890a 100644 --- a/src/Display/Extension/Actions.php +++ b/src/Display/Extension/Actions.php @@ -49,7 +49,7 @@ public function clear() */ public function set($actions) { - if (! is_array($actions)) { + if (!is_array($actions)) { $actions = func_get_args(); } @@ -145,13 +145,13 @@ public function initialize() return; } - $this->all()->each(function (ActionInterface $action) { + $this->all()->each(function(ActionInterface $action) { $action->initialize(); }); $this->setHtmlAttribute('data-type', 'display-actions'); - if (! $this->hasHtmlAttribute('class')) { + if (!$this->hasHtmlAttribute('class')) { $this->setHtmlAttribute('class', 'panel-footer'); } } diff --git a/src/Display/Extension/Apply.php b/src/Display/Extension/Apply.php index 124332b86..937b877aa 100644 --- a/src/Display/Extension/Apply.php +++ b/src/Display/Extension/Apply.php @@ -26,7 +26,7 @@ public function all() */ public function set($applies) { - if (! is_array($applies)) { + if (!is_array($applies)) { $applies = func_get_args(); } diff --git a/src/Display/Extension/ColumnFilters.php b/src/Display/Extension/ColumnFilters.php index 8bd670554..be8f0678f 100644 --- a/src/Display/Extension/ColumnFilters.php +++ b/src/Display/Extension/ColumnFilters.php @@ -35,7 +35,7 @@ class ColumnFilters extends Extension implements Initializable, Placable */ public function set($columnFilters) { - if (! is_array($columnFilters)) { + if (!is_array($columnFilters)) { $columnFilters = func_get_args(); } @@ -192,13 +192,13 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $display = $this->getDisplay(); - if (! $display->getExtensions()->has('columns')) { + if (!$display->getExtensions()->has('columns')) { return; } $columns = $display->getColumns()->all(); - if (! is_int(key($search))) { + if (!is_int(key($search))) { $search = [$search]; } @@ -235,7 +235,7 @@ protected function validNumberOfFilters() protected function prepareView() { - if (! in_array($this->getPlacement(), ['table.footer', 'table.header']) && $this->view == 'display.extensions.columns_filters_table') { + if (!in_array($this->getPlacement(), ['table.footer', 'table.header']) && $this->view == 'display.extensions.columns_filters_table') { $this->view = 'display.extensions.columns_filters'; $this->setHtmlAttribute('class', 'table table-default'); } diff --git a/src/Display/Extension/Columns.php b/src/Display/Extension/Columns.php index cb4963e95..2f9f37ffb 100644 --- a/src/Display/Extension/Columns.php +++ b/src/Display/Extension/Columns.php @@ -91,10 +91,10 @@ public function disableControls() $this->controlActive = false; if ($this->isInitialize()) { - $this->columns = $this->columns->filter(function ($column) { + $this->columns = $this->columns->filter(function($column) { $class = get_class($this->getControlColumn()); - return ! ($column instanceof $class); + return !($column instanceof $class); }); } @@ -116,7 +116,7 @@ public function all() */ public function set($columns) { - if (! is_array($columns)) { + if (!is_array($columns)) { $columns = func_get_args(); } @@ -162,7 +162,7 @@ public function toArray() public function initialize() { - $this->all()->each(function (ColumnInterface $column) { + $this->all()->each(function(ColumnInterface $column) { $column->initialize(); }); @@ -204,7 +204,7 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $columns = $this->all(); - if (! is_int(key($orders))) { + if (!is_int(key($orders))) { $orders = [$orders]; } @@ -212,7 +212,7 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $columnIndex = array_get($order, 'column'); $direction = array_get($order, 'dir', 'asc'); - if (! $columnIndex && $columnIndex !== '0') { + if (!$columnIndex && $columnIndex !== '0') { continue; } diff --git a/src/Display/Extension/ColumnsTotal.php b/src/Display/Extension/ColumnsTotal.php index ff017c742..a5faa75ce 100644 --- a/src/Display/Extension/ColumnsTotal.php +++ b/src/Display/Extension/ColumnsTotal.php @@ -35,8 +35,8 @@ public function __construct() public function set(array $elements, $columnsNumber = 0) { - array_map(function ($element) { - if (! is_object($element)) { + array_map(function($element) { + if (!is_object($element)) { $element = Element::create($element); } $this->elements->push($element); diff --git a/src/Display/Extension/Filters.php b/src/Display/Extension/Filters.php index 90cc4f9f6..d9b2306aa 100644 --- a/src/Display/Extension/Filters.php +++ b/src/Display/Extension/Filters.php @@ -41,7 +41,7 @@ public function clear() */ public function set($filters) { - if (! is_array($filters)) { + if (!is_array($filters)) { $filters = func_get_args(); } @@ -79,7 +79,7 @@ public function push(FilterInterface $filter) */ public function getActive() { - return $this->filters->filter(function (FilterInterface $filter) { + return $this->filters->filter(function(FilterInterface $filter) { return $filter->isActive(); }); } @@ -125,7 +125,7 @@ public function toArray() */ public function modifyQuery(Builder $query) { - $this->getActive()->each(function (FilterInterface $filter) use ($query) { + $this->getActive()->each(function(FilterInterface $filter) use ($query) { $filter->apply($query); }); } @@ -135,7 +135,7 @@ public function modifyQuery(Builder $query) */ public function initialize() { - $this->filters->each(function (FilterInterface $filter) { + $this->filters->each(function(FilterInterface $filter) { $filter->initialize(); }); } diff --git a/src/Display/Extension/Scopes.php b/src/Display/Extension/Scopes.php index fdb3bd506..a84ea4698 100644 --- a/src/Display/Extension/Scopes.php +++ b/src/Display/Extension/Scopes.php @@ -43,7 +43,7 @@ public function set($scopes) */ public function push($scope) { - if (! is_array($scope)) { + if (!is_array($scope)) { $scope = func_get_args(); } @@ -70,7 +70,7 @@ public function toArray() public function modifyQuery(Builder $query) { foreach ($this->scopes as $scope) { - if (! is_null($scope)) { + if (!is_null($scope)) { if (is_array($scope)) { $method = array_shift($scope); $params = $scope; diff --git a/src/Display/ExtensionCollection.php b/src/Display/ExtensionCollection.php index 1d47baa4d..24d6f7b71 100644 --- a/src/Display/ExtensionCollection.php +++ b/src/Display/ExtensionCollection.php @@ -15,7 +15,7 @@ class ExtensionCollection extends Collection */ public function placable() { - return $this->filter(function (DisplayExtensionInterface $extension) { + return $this->filter(function(DisplayExtensionInterface $extension) { return $extension instanceof Placable; }); } @@ -42,7 +42,7 @@ public function placableBlocks() */ public function renderable() { - return $this->filter(function (DisplayExtensionInterface $extension) { + return $this->filter(function(DisplayExtensionInterface $extension) { return $extension instanceof Renderable; }); } @@ -52,7 +52,7 @@ public function renderable() */ public function sortByOrder() { - return $this->sortBy(function (DisplayExtensionInterface $extension) { + return $this->sortBy(function(DisplayExtensionInterface $extension) { return $extension->getOrder(); }); } @@ -62,7 +62,7 @@ public function sortByOrder() */ public function initialize() { - $this->each(function (DisplayExtensionInterface $extension) { + $this->each(function(DisplayExtensionInterface $extension) { if ($extension instanceof Initializable) { $extension->initialize(); } @@ -76,7 +76,7 @@ public function initialize() */ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) { - $this->each(function (DisplayExtensionInterface $extension) use ($query) { + $this->each(function(DisplayExtensionInterface $extension) use ($query) { $extension->modifyQuery($query); }); diff --git a/src/Display/Filter/FilterBase.php b/src/Display/Filter/FilterBase.php index 988291b6c..d614c3427 100644 --- a/src/Display/Filter/FilterBase.php +++ b/src/Display/Filter/FilterBase.php @@ -35,7 +35,7 @@ public function __construct($name, $title = null) { $this->setName($name); - if (! is_null($title)) { + if (!is_null($title)) { $this->setTitle($title); } } @@ -77,7 +77,7 @@ public function setName($name) */ public function getAlias() { - if (! $this->alias) { + if (!$this->alias) { return $this->getName(); } @@ -149,6 +149,6 @@ public function setValue($value) */ public function isActive() { - return ! is_null($this->getValue()); + return !is_null($this->getValue()); } } diff --git a/src/Display/Filter/FilterCustom.php b/src/Display/Filter/FilterCustom.php index 9bf97347f..a9bda0498 100644 --- a/src/Display/Filter/FilterCustom.php +++ b/src/Display/Filter/FilterCustom.php @@ -21,7 +21,7 @@ public function __construct($name, $title = null, Closure $callback = null) { parent::__construct($name, $title); - if (! is_null($callback)) { + if (!is_null($callback)) { $this->setCallback($callback); } } diff --git a/src/Display/Filter/FilterField.php b/src/Display/Filter/FilterField.php index 1129b0d35..29ea6ce98 100644 --- a/src/Display/Filter/FilterField.php +++ b/src/Display/Filter/FilterField.php @@ -38,8 +38,8 @@ public function apply(Builder $query) $relationName = implode('.', $parts); } - if (! is_null($relationName)) { - $query->whereHas($relationName, function ($q) use ($name, $value) { + if (!is_null($relationName)) { + $query->whereHas($relationName, function($q) use ($name, $value) { $this->buildQuery($q, $name, $value); }); } else { diff --git a/src/Display/Filter/FilterRelated.php b/src/Display/Filter/FilterRelated.php index 46b570545..5e984e2ba 100644 --- a/src/Display/Filter/FilterRelated.php +++ b/src/Display/Filter/FilterRelated.php @@ -53,7 +53,7 @@ public function getModel() */ public function setModel($model) { - if (! class_exists($model)) { + if (!class_exists($model)) { throw new Exception("Class model [$model] not found"); } diff --git a/src/Display/TableColumn.php b/src/Display/TableColumn.php index ab88bdda9..233a06405 100644 --- a/src/Display/TableColumn.php +++ b/src/Display/TableColumn.php @@ -79,7 +79,7 @@ public function __construct($label = null) { $this->header = app(TableHeaderColumnInterface::class); - if (! is_null($label)) { + if (!is_null($label)) { $this->setLabel($label); } @@ -274,7 +274,7 @@ public function setOrderable($orderable) $orderable = new OrderByClause($orderable); } - if ($orderable !== false && ! $orderable instanceof OrderByClauseInterface) { + if ($orderable !== false && !$orderable instanceof OrderByClauseInterface) { throw new \InvalidArgumentException('Argument must be instance of SleepingOwl\Admin\Contracts\Display\OrderByClauseInterface interface'); } @@ -309,7 +309,7 @@ public function isOrderable() */ public function orderBy(Builder $query, $direction) { - if (! $this->isOrderable()) { + if (!$this->isOrderable()) { throw new \InvalidArgumentException('Argument must be instance of SleepingOwl\Admin\Contracts\Display\OrderByClauseInterface interface'); } diff --git a/src/Form/Buttons/Delete.php b/src/Form/Buttons/Delete.php index 49c695972..b6b6deb58 100644 --- a/src/Form/Buttons/Delete.php +++ b/src/Form/Buttons/Delete.php @@ -41,7 +41,7 @@ public function canShow() return false; } - $this->show = ! $this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); + $this->show = !$this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); return parent::canShow(); } diff --git a/src/Form/Buttons/Destroy.php b/src/Form/Buttons/Destroy.php index 29164da44..19e789933 100644 --- a/src/Form/Buttons/Destroy.php +++ b/src/Form/Buttons/Destroy.php @@ -36,7 +36,7 @@ public function initialize() */ public function canShow() { - if (is_null($this->getModel()->getKey()) || ! $this->show) { + if (is_null($this->getModel()->getKey()) || !$this->show) { return false; } diff --git a/src/Form/Buttons/Restore.php b/src/Form/Buttons/Restore.php index e748a9301..596305487 100644 --- a/src/Form/Buttons/Restore.php +++ b/src/Form/Buttons/Restore.php @@ -38,7 +38,7 @@ public function initialize() */ public function canShow() { - if (is_null($this->getModel()->getKey()) || ! $this->show) { + if (is_null($this->getModel()->getKey()) || !$this->show) { return false; } diff --git a/src/Form/Columns/Columns.php b/src/Form/Columns/Columns.php index 9ab2904da..405c980f8 100644 --- a/src/Form/Columns/Columns.php +++ b/src/Form/Columns/Columns.php @@ -70,7 +70,7 @@ public function addElement($element, $width = null) $element = new Column($element); } - if (! ($element instanceof ColumnInterface)) { + if (!($element instanceof ColumnInterface)) { throw new \Exception('Column should be instance of ColumnInterface'); } @@ -85,16 +85,16 @@ public function initialize() { $this->setHtmlAttribute('class', 'row'); - $count = $this->getElements()->filter(function (ColumnInterface $column) { + $count = $this->getElements()->filter(function(ColumnInterface $column) { return $column->getWidth() === 0; })->count(); - $width = $this->maxWidth - $this->getElements()->sum(function (ColumnInterface $column) { + $width = $this->maxWidth - $this->getElements()->sum(function(ColumnInterface $column) { return $column->getWidth(); }); - $this->getElements()->each(function (ColumnInterface $column) use ($width, $count) { - if (! $column->getWidth()) { + $this->getElements()->each(function(ColumnInterface $column) use ($width, $count) { + if (!$column->getWidth()) { $column->setWidth(floor($width / $count)); } }); @@ -134,7 +134,7 @@ public function getSize() */ public function setSize($size) { - $this->getColumns()->each(function (ColumnInterface $column) use ($size) { + $this->getColumns()->each(function(ColumnInterface $column) use ($size) { $column->setSize($size); }); } diff --git a/src/Form/Element/Custom.php b/src/Form/Element/Custom.php index fca9f582b..2f7cfc61c 100644 --- a/src/Form/Element/Custom.php +++ b/src/Form/Element/Custom.php @@ -26,7 +26,7 @@ class Custom extends FormElement */ public function __construct(Closure $callback = null) { - if (! is_null($callback)) { + if (!is_null($callback)) { $this->setCallback($callback); } diff --git a/src/Form/Element/DateRange.php b/src/Form/Element/DateRange.php index 7c3e8fa1c..ee4097434 100644 --- a/src/Form/Element/DateRange.php +++ b/src/Form/Element/DateRange.php @@ -31,7 +31,7 @@ class DateRange extends Date */ public function getDefaultFrom() { - if (! $this->defaultFrom) { + if (!$this->defaultFrom) { $this->defaultFrom = Carbon::now(); } @@ -57,7 +57,7 @@ public function setDefaultFrom($defaultFrom) */ public function getDefaultTo() { - if (! $this->defaultTo) { + if (!$this->defaultTo) { $this->defaultTo = Carbon::now(); } @@ -85,7 +85,7 @@ public function setDefaultTo($defaultTo) */ public function setModelAttribute($value) { - $value = ! empty($value) ? array_map(function ($date) { + $value = !empty($value) ? array_map(function($date) { return Carbon::createFromFormat($this->getPickerFormat(), $date); }, explode('::', $value)) : null; diff --git a/src/Form/Element/DateTime.php b/src/Form/Element/DateTime.php index 86a5c270a..7c7ebff88 100644 --- a/src/Form/Element/DateTime.php +++ b/src/Form/Element/DateTime.php @@ -79,7 +79,7 @@ public function setTimezone($timezone) public function getValueFromModel() { $value = parent::getValueFromModel(); - if (! empty($value)) { + if (!empty($value)) { return $this->parseValue($value); } } @@ -111,7 +111,7 @@ public function setSeconds($seconds) */ public function setModelAttribute($value) { - $value = ! empty($value) + $value = !empty($value) ? Carbon::createFromFormat($this->getPickerFormat(), $value, $this->getTimezone()) ->timezone(config('app.timezone'))->format($this->getFormat()) : null; diff --git a/src/Form/Element/DependentSelect.php b/src/Form/Element/DependentSelect.php index f4e2fbc10..34eea3b3f 100644 --- a/src/Form/Element/DependentSelect.php +++ b/src/Form/Element/DependentSelect.php @@ -14,7 +14,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.dependent-select'; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/dependent-select/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@dependentSelect', diff --git a/src/Form/Element/File.php b/src/Form/Element/File.php index 2ec8b766d..e7b4df056 100644 --- a/src/Form/Element/File.php +++ b/src/Form/Element/File.php @@ -27,7 +27,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\UploadController@fromField', @@ -127,7 +127,7 @@ public function getUploadValidationRules() */ public function getUploadPath(UploadedFile $file) { - if (! is_callable($this->uploadPath)) { + if (!is_callable($this->uploadPath)) { return $this->defaultUploadPath($file); } @@ -153,7 +153,7 @@ public function setUploadPath(Closure $uploadPath) */ public function getUploadFileName(UploadedFile $file) { - if (! is_callable($this->uploadFileName)) { + if (!is_callable($this->uploadFileName)) { return $this->defaultUploadFilename($file); } diff --git a/src/Form/Element/Image.php b/src/Form/Element/Image.php index d5cefe3cf..64fdc0092 100644 --- a/src/Form/Element/Image.php +++ b/src/Form/Element/Image.php @@ -37,13 +37,13 @@ class Image extends File */ public function customValidation(Validator $validator) { - $validator->after(function (Validator $validator) { + $validator->after(function(Validator $validator) { /** @var \Illuminate\Http\UploadedFile $file */ $file = array_get($validator->attributes(), 'file'); $size = getimagesize($file->getRealPath()); - if (! $size && $file->getMimeType() !== 'image/svg+xml') { + if (!$size && $file->getMimeType() !== 'image/svg+xml') { $validator->errors()->add('file', trans('sleeping_owl::validation.not_image')); } }); diff --git a/src/Form/Element/Images.php b/src/Form/Element/Images.php index f8dd987b8..1a15bbf98 100644 --- a/src/Form/Element/Images.php +++ b/src/Form/Element/Images.php @@ -15,7 +15,7 @@ class Images extends Image */ public function storeAsJson() { - $this->mutateValue(function ($value) { + $this->mutateValue(function($value) { return json_encode($value); }); @@ -29,7 +29,7 @@ public function storeAsJson() */ public function storeAsComaSeparatedValue() { - $this->mutateValue(function ($value) { + $this->mutateValue(function($value) { return implode(',', $value); }); @@ -65,7 +65,7 @@ public function save(\Illuminate\Http\Request $request) $name = $this->getName(); $value = $request->input($name, ''); - if (! empty($value)) { + if (!empty($value)) { $value = explode(',', $value); } else { $value = []; diff --git a/src/Form/Element/MultiSelect.php b/src/Form/Element/MultiSelect.php index 16a637439..30facec1e 100644 --- a/src/Form/Element/MultiSelect.php +++ b/src/Form/Element/MultiSelect.php @@ -195,7 +195,7 @@ protected function syncBelongsToManyRelation( array $values ) { foreach ($values as $i => $value) { - if (! array_key_exists($value, $this->getOptions()) && $this->isTaggable()) { + if (!array_key_exists($value, $this->getOptions()) && $this->isTaggable()) { $model = clone $this->getModelForOptions(); $model->{$this->getDisplay()} = $value; $model->save(); @@ -225,7 +225,7 @@ protected function deleteOldItemsFromHasManyRelation( $items = $relation->get(); foreach ($items as $item) { - if (! in_array($item->getKey(), $values)) { + if (!in_array($item->getKey(), $values)) { if ($this->isDeleteRelatedItem()) { $item->delete(); } else { @@ -250,7 +250,7 @@ protected function attachItemsToHasManyRelation( $item = $model->find($value); if (is_null($item)) { - if (! $this->isTaggable()) { + if (!$this->isTaggable()) { continue; } diff --git a/src/Form/Element/MultiSelectAjax.php b/src/Form/Element/MultiSelectAjax.php index 45f671f47..90cd8f403 100644 --- a/src/Form/Element/MultiSelectAjax.php +++ b/src/Form/Element/MultiSelectAjax.php @@ -34,7 +34,7 @@ public function __construct($path, $label = null) { parent::__construct($path, $label); - $this->setLoadOptionsQueryPreparer(function ($item, Builder $query) { + $this->setLoadOptionsQueryPreparer(function($item, Builder $query) { $repository = app(RepositoryInterface::class); $repository->setModel($this->getModelForOptions()); $key = $repository->getModel()->getKeyName(); @@ -107,7 +107,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@multiselectSearch', @@ -175,7 +175,7 @@ protected function loadOptions() $options = $repository->getQuery(); $relation = $this->getModelAttributeKey(); - if ($this->isEmptyRelation() && ! is_null($foreignKey = $this->getForeignKey())) { + if ($this->isEmptyRelation() && !is_null($foreignKey = $this->getForeignKey())) { $model = $this->getModel(); if ($model->{$relation}() instanceof HasOneOrMany) { @@ -190,7 +190,7 @@ protected function loadOptions() } // call the pre load options query preparer if has be set - if (! is_null($preparer = $this->getLoadOptionsQueryPreparer())) { + if (!is_null($preparer = $this->getLoadOptionsQueryPreparer())) { $options = $preparer($this, $options); } @@ -208,7 +208,7 @@ protected function loadOptions() // iterate for all options and redefine it as // list of KEY and TEXT pair - $options = array_map(function ($opt) use ($key, $makeDisplay) { + $options = array_map(function($opt) use ($key, $makeDisplay) { // get the KEY and make the display text return [data_get($opt, $key), $makeDisplay($opt)]; }, $options); @@ -235,7 +235,7 @@ public function afterSave(Request $request) { $attribute = $this->getModelAttributeKey(); - if (! method_exists($this->getModel(), $attribute)) { + if (!method_exists($this->getModel(), $attribute)) { return; } diff --git a/src/Form/Element/NamedFormElement.php b/src/Form/Element/NamedFormElement.php index 746f76ca4..fef022d3b 100644 --- a/src/Form/Element/NamedFormElement.php +++ b/src/Form/Element/NamedFormElement.php @@ -85,7 +85,7 @@ private function composeName(array $parts) { $name = array_shift($parts); - while (! empty($parts)) { + while (!empty($parts)) { $part = array_shift($parts); $name .= "[$part]"; } @@ -238,7 +238,7 @@ public function unique($message = null) { $this->addValidationRule('_unique'); - if (! is_null($message)) { + if (!is_null($message)) { $this->addValidationMessage('unique', $message); } @@ -346,7 +346,7 @@ public function resolvePath() */ public function getValueFromRequest(\Illuminate\Http\Request $request) { - if ($request->hasSession() && ! is_null($value = $request->old($this->getPath()))) { + if ($request->hasSession() && !is_null($value = $request->old($this->getPath()))) { return $value; } @@ -358,7 +358,7 @@ public function getValueFromRequest(\Illuminate\Http\Request $request) */ public function getValueFromModel() { - if (! is_null($value = $this->getValueFromRequest(request()))) { + if (!is_null($value = $this->getValueFromRequest(request()))) { return $value; } @@ -366,7 +366,7 @@ public function getValueFromModel() $path = $this->getPath(); $value = $this->getDefaultValue(); - if (is_null($model) || ! $model->exists) { + if (is_null($model) || !$model->exists) { return $value; } @@ -396,7 +396,7 @@ public function getValueFromModel() if ($count === 1) { $attribute = $model->getAttribute($this->getModelAttributeKey()); - if (! empty($attribute) || $attribute === 0 || is_null($value)) { + if (!empty($attribute) || $attribute === 0 || is_null($value)) { return $attribute; } } @@ -410,7 +410,7 @@ public function getValueFromModel() if ($count === 2) { $attribute = $model->getAttribute($relation); - if (! empty($attribute) || is_null($value)) { + if (!empty($attribute) || is_null($value)) { return $attribute; } } diff --git a/src/Form/Element/Password.php b/src/Form/Element/Password.php index f25f51f66..22b730fe8 100644 --- a/src/Form/Element/Password.php +++ b/src/Form/Element/Password.php @@ -33,7 +33,7 @@ public function save(\Illuminate\Http\Request $request) { $value = $this->getValueFromModel(); - if (! $this->isAllowedEmptyValue() && $this->getModel()->exists && empty($value)) { + if (!$this->isAllowedEmptyValue() && $this->getModel()->exists && empty($value)) { return; } @@ -47,7 +47,7 @@ public function getValidationRules() { $data = parent::getValidationRules(); - if (! $this->isAllowedEmptyValue() && $this->getModel()->exists) { + if (!$this->isAllowedEmptyValue() && $this->getModel()->exists) { foreach ($data as $field => $rules) { foreach ($rules as $i => $rule) { if ($rule == 'required') { @@ -83,7 +83,7 @@ public function allowEmptyValue() */ public function hashWithBcrypt() { - return $this->mutateValue(function ($value) { + return $this->mutateValue(function($value) { return bcrypt($value); }); } @@ -93,7 +93,7 @@ public function hashWithBcrypt() */ public function hashWithMD5() { - return $this->mutateValue(function ($value) { + return $this->mutateValue(function($value) { return md5($value); }); } @@ -103,7 +103,7 @@ public function hashWithMD5() */ public function hashWithSHA1() { - return $this->mutateValue(function ($value) { + return $this->mutateValue(function($value) { return sha1($value); }); } diff --git a/src/Form/Element/SelectAjax.php b/src/Form/Element/SelectAjax.php index bcb011468..352928754 100644 --- a/src/Form/Element/SelectAjax.php +++ b/src/Form/Element/SelectAjax.php @@ -23,7 +23,7 @@ public function __construct($path, $label = null) { parent::__construct($path, $label); - $this->setLoadOptionsQueryPreparer(function ($item, Builder $query) { + $this->setLoadOptionsQueryPreparer(function($item, Builder $query) { $repository = app(RepositoryInterface::class); $repository->setModel($this->getModelForOptions()); $key = $repository->getModel()->getKeyName(); @@ -39,7 +39,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (! $router->has($routeName)) { + if (!$router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@selectSearch', diff --git a/src/Form/Element/Upload.php b/src/Form/Element/Upload.php index 19a7ab7e2..68f104dc8 100644 --- a/src/Form/Element/Upload.php +++ b/src/Form/Element/Upload.php @@ -42,7 +42,7 @@ public function save(\Illuminate\Http\Request $request) if ($request->input($this->getPath().'_remove')) { $this->setModelAttribute(null); - } elseif (! is_null($value)) { + } elseif (!is_null($value)) { $this->setModelAttribute($value); } } diff --git a/src/Form/Element/View.php b/src/Form/Element/View.php index ea3cd0b6f..6d3bc337e 100644 --- a/src/Form/Element/View.php +++ b/src/Form/Element/View.php @@ -46,7 +46,7 @@ public function setView($view) { $this->view = $view; - $this->setDisplay(function ($model) { + $this->setDisplay(function($model) { $this->data['model'] = $model; return view($this->getView(), $this->data); diff --git a/src/Form/Element/Wysiwyg.php b/src/Form/Element/Wysiwyg.php index f045a66a8..f59dec527 100644 --- a/src/Form/Element/Wysiwyg.php +++ b/src/Form/Element/Wysiwyg.php @@ -62,7 +62,7 @@ public function initialize() $config = $editor->getConfig(); $config->set($this->parameters); - if (! $this->hasHtmlAttribute('id')) { + if (!$this->hasHtmlAttribute('id')) { $this->setHtmlAttribute('id', $this->getName()); } @@ -70,11 +70,11 @@ public function initialize() $params = collect($this->parameters); - if (! $params->has('uploadUrl')) { + if (!$params->has('uploadUrl')) { $this->parameters['uploadUrl'] = route('admin.ckeditor.upload'); } - if (! $params->has('filebrowserUploadUrl')) { + if (!$params->has('filebrowserUploadUrl')) { $this->parameters['filebrowserUploadUrl'] = route('admin.ckeditor.upload'); } } @@ -179,7 +179,7 @@ public function toArray() */ public function setModelAttribute($value) { - if (! empty($this->filteredFieldKey)) { + if (!empty($this->filteredFieldKey)) { parent::setModelAttribute($value); $this->setModelAttributeKey($this->filteredFieldKey); diff --git a/src/Form/FormButtons.php b/src/Form/FormButtons.php index b97d5c36c..96301b218 100644 --- a/src/Form/FormButtons.php +++ b/src/Form/FormButtons.php @@ -457,11 +457,11 @@ public function hideSaveAndCreateButton() */ public function isShowDeleteButton() { - if (is_null($this->getModel()->getKey()) || ! $this->showDeleteButton) { + if (is_null($this->getModel()->getKey()) || !$this->showDeleteButton) { return false; } - $this->showDeleteButton = ! $this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); + $this->showDeleteButton = !$this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); return $this->showDeleteButton; } @@ -483,7 +483,7 @@ public function hideDeleteButton() */ public function isShowDestroyButton() { - if (is_null($this->getModel()->getKey()) || ! $this->showDestroyButton) { + if (is_null($this->getModel()->getKey()) || !$this->showDestroyButton) { return false; } @@ -510,7 +510,7 @@ public function hideDestroyButton() */ public function isShowRestoreButton() { - if (is_null($this->getModel()->getKey()) || ! $this->showRestoreButton) { + if (is_null($this->getModel()->getKey()) || !$this->showRestoreButton) { return false; } diff --git a/src/Form/FormDefault.php b/src/Form/FormDefault.php index 6f4ea0053..0b122b429 100644 --- a/src/Form/FormDefault.php +++ b/src/Form/FormDefault.php @@ -100,11 +100,11 @@ public function initialize() parent::initialize(); - if (! $this->hasHtmlAttribute('enctype')) { + if (!$this->hasHtmlAttribute('enctype')) { // Try to find upload element - $this->getElements()->each(function ($element) { + $this->getElements()->each(function($element) { // Try to get nested - will be implemented - if ($element instanceof Upload && ! $this->hasHtmlAttribute('enctype')) { + if ($element instanceof Upload && !$this->hasHtmlAttribute('enctype')) { $this->setHtmlAttribute('enctype', 'multipart/form-data'); } }); @@ -209,7 +209,7 @@ public function getItems() */ public function setItems($items) { - if (! is_array($items)) { + if (!is_array($items)) { $items = func_get_args(); } @@ -236,7 +236,7 @@ public function addItem($item) */ public function setId($id) { - if (is_null($this->id) && ! is_null($id) && ($model = $this->getRepository()->find($id))) { + if (is_null($this->id) && !is_null($id) && ($model = $this->getRepository()->find($id))) { $this->id = $id; parent::setModel($model); @@ -297,7 +297,7 @@ public function validModelConfiguration(ModelConfigurationInterface $modelConfig */ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) { - if (! $this->validModelConfiguration($modelConfiguration)) { + if (!$this->validModelConfiguration($modelConfiguration)) { return false; } @@ -337,7 +337,7 @@ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationIn protected function saveBelongsToRelations(Model $model) { foreach ($model->getRelations() as $name => $relation) { - if ($model->{$name}() instanceof BelongsTo && ! is_null($relation)) { + if ($model->{$name}() instanceof BelongsTo && !is_null($relation)) { $relation->save(); $model->{$name}()->associate($relation); } @@ -352,7 +352,7 @@ protected function saveBelongsToRelations(Model $model) protected function saveHasOneRelations(Model $model) { foreach ($model->getRelations() as $name => $relation) { - if ($model->{$name}() instanceof HasOneOrMany && ! is_null($relation)) { + if ($model->{$name}() instanceof HasOneOrMany && !is_null($relation)) { if (is_array($relation) || $relation instanceof \Traversable) { $model->{$name}()->saveMany($relation); } else { @@ -370,7 +370,7 @@ protected function saveHasOneRelations(Model $model) */ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) { - if (! $this->validModelConfiguration($modelConfiguration)) { + if (!$this->validModelConfiguration($modelConfiguration)) { return; } diff --git a/src/Form/FormElement.php b/src/Form/FormElement.php index a8bc700e9..a14bd077f 100644 --- a/src/Form/FormElement.php +++ b/src/Form/FormElement.php @@ -137,7 +137,7 @@ public function addValidationRule($rule, $message = null) */ public function setValidationRules($validationRules) { - if (! is_array($validationRules)) { + if (!is_array($validationRules)) { $validationRules = func_get_args(); } diff --git a/src/Form/FormElementsCollection.php b/src/Form/FormElementsCollection.php index a40bafb77..f9964be6d 100644 --- a/src/Form/FormElementsCollection.php +++ b/src/Form/FormElementsCollection.php @@ -12,9 +12,9 @@ class FormElementsCollection extends Collection */ public function onlyActive() { - return $this->filter(function ($element) { + return $this->filter(function($element) { if ($element instanceof FormElementInterface) { - return ! $element->isReadonly(); + return !$element->isReadonly(); } return true; @@ -26,7 +26,7 @@ public function onlyActive() */ public function onlyVisible() { - return $this->filter(function ($element) { + return $this->filter(function($element) { if ($element instanceof FormElementInterface) { return $element->isVisible(); } diff --git a/src/Form/FormPanel.php b/src/Form/FormPanel.php index ad5e431f3..4afb4a737 100644 --- a/src/Form/FormPanel.php +++ b/src/Form/FormPanel.php @@ -40,7 +40,7 @@ public function initialize() */ public function setItems($items) { - if (! is_array($items)) { + if (!is_array($items)) { $items = func_get_args(); } @@ -72,7 +72,7 @@ public function addItem($item) */ public function addHeader($items) { - if (! is_array($items)) { + if (!is_array($items)) { $items = func_get_args(); } @@ -88,7 +88,7 @@ public function addHeader($items) */ public function addBody($items) { - if (! is_array($items)) { + if (!is_array($items)) { $items = func_get_args(); } @@ -109,7 +109,7 @@ public function addBody($items) */ public function addFooter($items) { - if (! is_array($items)) { + if (!is_array($items)) { $items = func_get_args(); } diff --git a/src/Http/Controllers/AdminController.php b/src/Http/Controllers/AdminController.php index 980adfc2f..f424aa38d 100644 --- a/src/Http/Controllers/AdminController.php +++ b/src/Http/Controllers/AdminController.php @@ -60,8 +60,8 @@ public function __construct(Request $request, AdminInterface $admin, Application $admin->navigation()->setCurrentUrl($request->getUri()); - if (! $this->breadcrumbs->exists('home')) { - $this->breadcrumbs->register('home', function (Generator $breadcrumbs) { + if (!$this->breadcrumbs->exists('home')) { + $this->breadcrumbs->register('home', function(Generator $breadcrumbs) { $breadcrumbs->push(trans('sleeping_owl::lang.dashboard'), route('admin.dashboard')); }); } @@ -118,7 +118,7 @@ public function getDashboard() */ public function getDisplay(ModelConfigurationInterface $model) { - if (! $model->isDisplayable()) { + if (!$model->isDisplayable()) { abort(404); } @@ -138,7 +138,7 @@ public function getDisplay(ModelConfigurationInterface $model) */ public function getCreate(ModelConfigurationInterface $model) { - if (! $model->isCreatable()) { + if (!$model->isCreatable()) { abort(404); } @@ -158,7 +158,7 @@ public function getCreate(ModelConfigurationInterface $model) */ public function postStore(ModelConfigurationInterface $model, Request $request) { - if (! $model->isCreatable()) { + if (!$model->isCreatable()) { abort(404); } @@ -196,7 +196,7 @@ public function postStore(ModelConfigurationInterface $model, Request $request) $redirectPolicy = $model->getRedirect(); /* Make redirect when use in model config && Fix editable redirect */ - if ($redirectPolicy->get('create') == 'display' || ! $model->isEditable($newModel)) { + if ($redirectPolicy->get('create') == 'display' || !$model->isEditable($newModel)) { $redirectUrl = $model->getDisplayUrl(); } @@ -235,7 +235,7 @@ public function getEdit(ModelConfigurationInterface $model, $id) { $item = $model->getRepository()->find($id); - if (is_null($item) || ! $model->isEditable($item)) { + if (is_null($item) || !$model->isEditable($item)) { abort(404); } @@ -263,7 +263,7 @@ public function postUpdate(ModelConfigurationInterface $model, Request $request, $editForm = $model->fireEdit($id); $item = $editForm->getModel(); - if (is_null($item) || ! $model->isEditable($item)) { + if (is_null($item) || !$model->isEditable($item)) { abort(404); } @@ -342,7 +342,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) /* @var ColumnEditableInterface|null $column */ if (is_callable([$display, 'getColumns'])) { - $column = $display->getColumns()->all()->filter(function ($column) use ($field) { + $column = $display->getColumns()->all()->filter(function($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } else { @@ -351,7 +351,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) $content = $tab->getContent(); if ($content instanceof DisplayTable) { - $column = $content->getColumns()->all()->filter(function ($column) use ($field) { + $column = $content->getColumns()->all()->filter(function($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -360,7 +360,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) //Return data-table if inside FormElements if ($element instanceof DisplayTable) { - $column = $element->getColumns()->all()->filter(function ($column) use ($field) { + $column = $element->getColumns()->all()->filter(function($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -369,7 +369,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) if ($element instanceof Column) { foreach ($element->getElements() as $columnElement) { if ($columnElement instanceof DisplayTable) { - $column = $columnElement->getColumns()->all()->filter(function ($column) use ($field) { + $column = $columnElement->getColumns()->all()->filter(function($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -388,7 +388,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) $repository = $model->getRepository(); $item = $repository->find($id); - if (is_null($item) || ! $model->isEditable($item)) { + if (is_null($item) || !$model->isEditable($item)) { abort(404); } @@ -413,7 +413,7 @@ public function deleteDelete(ModelConfigurationInterface $model, Request $reques { $item = $model->getRepository()->find($id); - if (is_null($item) || ! $model->isDeletable($item)) { + if (is_null($item) || !$model->isDeletable($item)) { abort(404); } @@ -442,13 +442,13 @@ public function deleteDelete(ModelConfigurationInterface $model, Request $reques */ public function deleteDestroy(ModelConfigurationInterface $model, Request $request, $id) { - if (! $model->isRestorableModel()) { + if (!$model->isRestorableModel()) { abort(404); } $item = $model->getRepository()->findOnlyTrashed($id); - if (is_null($item) || ! $model->isRestorable($item)) { + if (is_null($item) || !$model->isRestorable($item)) { abort(404); } @@ -477,13 +477,13 @@ public function deleteDestroy(ModelConfigurationInterface $model, Request $reque */ public function postRestore(ModelConfigurationInterface $model, Request $request, $id) { - if (! $model->isRestorableModel()) { + if (!$model->isRestorableModel()) { abort(404); } $item = $model->getRepository()->findOnlyTrashed($id); - if (is_null($item) || ! $model->isRestorable($item)) { + if (is_null($item) || !$model->isRestorable($item)) { abort(404); } @@ -568,7 +568,7 @@ public function getWildcard() */ protected function registerBreadcrumb($title, $parent) { - $this->breadcrumbs->register('render', function (Generator $breadcrumbs) use ($title, $parent) { + $this->breadcrumbs->register('render', function(Generator $breadcrumbs) use ($title, $parent) { $breadcrumbs->parent($parent); $breadcrumbs->push($title); }); @@ -584,8 +584,8 @@ protected function registerBreadcrumbs(ModelConfigurationInterface $model) $this->breadCrumbsData = $this->breadCrumbsData + (array) $model->getBreadCrumbs(); foreach ($this->breadCrumbsData as $breadcrumb) { - if (! $this->breadcrumbs->exists($breadcrumb['id'])) { - $this->breadcrumbs->register($breadcrumb['id'], function (Generator $breadcrumbs) use ($breadcrumb) { + if (!$this->breadcrumbs->exists($breadcrumb['id'])) { + $this->breadcrumbs->register($breadcrumb['id'], function(Generator $breadcrumbs) use ($breadcrumb) { $breadcrumbs->parent($breadcrumb['parent']); $breadcrumbs->push($breadcrumb['title'], $breadcrumb['url']); }); diff --git a/src/Http/Controllers/DisplayController.php b/src/Http/Controllers/DisplayController.php index 4f44dbeb6..9574438f1 100644 --- a/src/Http/Controllers/DisplayController.php +++ b/src/Http/Controllers/DisplayController.php @@ -86,7 +86,7 @@ public function treeReorder(ModelConfigurationInterface $model, Request $request $display = $model->fireDisplay(); if ($display instanceof DisplayTabbed) { - $display->getTabs()->each(function (DisplayTab $tab) use ($request) { + $display->getTabs()->each(function(DisplayTab $tab) use ($request) { $content = $tab->getContent(); if ($content instanceof DisplayTree) { $content->getRepository()->reorder( diff --git a/src/Http/Controllers/FormElementController.php b/src/Http/Controllers/FormElementController.php index 05addc36a..5f0b1a67f 100644 --- a/src/Http/Controllers/FormElementController.php +++ b/src/Http/Controllers/FormElementController.php @@ -18,9 +18,9 @@ class FormElementController extends Controller */ public function getModelLogic(ModelConfigurationInterface $model, $id = null) { - if (! is_null($id)) { + if (!is_null($id)) { $item = $model->getRepository()->find($id); - if (is_null($item) || ! $model->isEditable($item)) { + if (is_null($item) || !$model->isEditable($item)) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -29,7 +29,7 @@ public function getModelLogic(ModelConfigurationInterface $model, $id = null) return $model->fireEdit($id); } - if (! $model->isCreatable()) { + if (!$model->isCreatable()) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -74,7 +74,7 @@ public function dependentSelect(Request $request, ModelConfigurationInterface $m } return new JsonResponse([ - 'output' => collect($options)->map(function ($value, $key) { + 'output' => collect($options)->map(function($value, $key) { return ['id' => $key, 'name' => $value]; }), 'selected' => $element->getValueFromModel(), @@ -126,7 +126,7 @@ public function selectSearch(Request $request, ModelConfigurationInterface $mode return new JsonResponse( $model::where($request->search, 'like', "%{$request->q}%") ->get() - ->map(function (Model $item) use ($field) { + ->map(function(Model $item) use ($field) { return [ 'tag_name' => $item->{$field}, 'id' => $item->id, diff --git a/src/Http/Controllers/UploadController.php b/src/Http/Controllers/UploadController.php index afcce4cd7..7d31470f7 100644 --- a/src/Http/Controllers/UploadController.php +++ b/src/Http/Controllers/UploadController.php @@ -23,9 +23,9 @@ class UploadController extends Controller */ public function fromField(Request $request, ModelConfigurationInterface $model, $field, $id = null) { - if (! is_null($id)) { + if (!is_null($id)) { $item = $model->getRepository()->find($id); - if (is_null($item) || ! $model->isEditable($item)) { + if (is_null($item) || !$model->isEditable($item)) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -33,7 +33,7 @@ public function fromField(Request $request, ModelConfigurationInterface $model, $form = $model->fireEdit($id); } else { - if (! $model->isCreatable()) { + if (!$model->isCreatable()) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); diff --git a/src/Http/routes.php b/src/Http/routes.php index 33414a1dc..bdb120893 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -2,8 +2,8 @@ use Illuminate\Routing\Router; -$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function (Router $router) { - if (! $router->has('admin.dashboard')) { +$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function(Router $router) { + if (!$router->has('admin.dashboard')) { $router->get('', ['as' => 'dashboard', 'uses' => 'AdminController@getDashboard']); } diff --git a/src/Model/ModelCollection.php b/src/Model/ModelCollection.php index 80e81ec79..977b61bf3 100644 --- a/src/Model/ModelCollection.php +++ b/src/Model/ModelCollection.php @@ -12,7 +12,7 @@ class ModelCollection extends Collection */ public function aliases() { - return $this->map(function (ModelConfigurationInterface $model) { + return $this->map(function(ModelConfigurationInterface $model) { return $model->getAlias(); }); } @@ -22,7 +22,7 @@ public function aliases() */ public function keyByAlias() { - return $this->keyBy(function (ModelConfigurationInterface $model) { + return $this->keyBy(function(ModelConfigurationInterface $model) { return $model->getAlias(); }); } diff --git a/src/Model/ModelConfiguration.php b/src/Model/ModelConfiguration.php index f00b50630..ba77e5b8d 100644 --- a/src/Model/ModelConfiguration.php +++ b/src/Model/ModelConfiguration.php @@ -229,7 +229,7 @@ public function disableDisplay() */ public function can($action, Model $model) { - if (! $this->checkAccess) { + if (!$this->checkAccess) { return true; } @@ -241,7 +241,7 @@ public function can($action, Model $model) */ public function isCreatable() { - if (! is_callable($this->getCreate())) { + if (!is_callable($this->getCreate())) { return false; } @@ -265,7 +265,7 @@ public function disableCreating() */ public function isEditable(Model $model) { - if (! is_callable($this->getEdit())) { + if (!is_callable($this->getEdit())) { return false; } @@ -388,7 +388,7 @@ public function onDisplay(Closure $callback) */ public function fireDisplay(array $payload = []) { - if (! is_callable($this->getDisplay())) { + if (!is_callable($this->getDisplay())) { return; } @@ -434,7 +434,7 @@ public function onCreate(Closure $callback = null) */ public function fireCreate() { - if (! is_callable($this->getCreate())) { + if (!is_callable($this->getCreate())) { return; } @@ -481,7 +481,7 @@ public function onEdit(Closure $callback = null) */ public function fireEdit($id) { - if (! is_callable($this->getEdit())) { + if (!is_callable($this->getEdit())) { return; } diff --git a/src/Model/ModelConfigurationManager.php b/src/Model/ModelConfigurationManager.php index 6505f2ad8..0a725820e 100644 --- a/src/Model/ModelConfigurationManager.php +++ b/src/Model/ModelConfigurationManager.php @@ -115,7 +115,7 @@ public function __construct(\Illuminate\Contracts\Foundation\Application $app, $ $this->repository = $app->make(RepositoryInterface::class); $this->repository->setClass($class); - if (! $this->alias) { + if (!$this->alias) { $this->setDefaultAlias(); } } @@ -304,7 +304,7 @@ public function disableAccessCheck() */ public function can($action, Model $model) { - if (! $this->checkAccess) { + if (!$this->checkAccess) { return true; } @@ -338,7 +338,7 @@ public function hasCustomControllerClass() { $controller = $this->getControllerClass(); - return ! is_null($controller) && class_exists($controller); + return !is_null($controller) && class_exists($controller); } /** @@ -517,7 +517,7 @@ protected function makePage($priority = 100, $badge = null) $page->setPriority($priority); if ($badge) { - if (! ($badge instanceof BadgeInterface)) { + if (!($badge instanceof BadgeInterface)) { $badge = new Badge($badge); } @@ -558,7 +558,7 @@ public function getRedirect() */ public function fireEvent($event, $halt = true, Model $model = null, ...$payload) { - if (! isset(self::$dispatcher)) { + if (!isset(self::$dispatcher)) { return true; } diff --git a/src/Model/SectionModelConfiguration.php b/src/Model/SectionModelConfiguration.php index 3d799a7a7..e6b654cda 100644 --- a/src/Model/SectionModelConfiguration.php +++ b/src/Model/SectionModelConfiguration.php @@ -64,7 +64,7 @@ public function isDeletable(Model $model) */ public function fireDisplay(array $payload = []) { - if (! method_exists($this, 'onDisplay')) { + if (!method_exists($this, 'onDisplay')) { return; } @@ -87,7 +87,7 @@ public function fireDisplay(array $payload = []) */ public function fireCreate() { - if (! method_exists($this, 'onCreate')) { + if (!method_exists($this, 'onCreate')) { return; } @@ -114,7 +114,7 @@ public function fireCreate() */ public function fireEdit($id) { - if (! method_exists($this, 'onEdit')) { + if (!method_exists($this, 'onEdit')) { return; } diff --git a/src/Navigation.php b/src/Navigation.php index e46ddcac5..f63f93b91 100644 --- a/src/Navigation.php +++ b/src/Navigation.php @@ -30,7 +30,7 @@ public function getCurrentPage() */ public function setAliasesId(Collection $pages) { - $pages->each(function (PageInterface $page) { + $pages->each(function(PageInterface $page) { $page->setAliasId(); if ($page->getPages()->count()) { @@ -54,7 +54,7 @@ protected function findActive($url, array &$foundPages) */ protected function findPageByAliasId(Collection $pages, $url) { - $pages->each(function (PageInterface $page) use ($url) { + $pages->each(function(PageInterface $page) use ($url) { $urlPath = parse_url($url, PHP_URL_PATH); if (Route::current()) { @@ -86,7 +86,7 @@ protected function findPageByAliasId(Collection $pages, $url) */ protected function findActivePage() { - if (! is_null($this->currentPage)) { + if (!is_null($this->currentPage)) { return true; } @@ -96,7 +96,7 @@ protected function findActivePage() $this->findActive($url, $foundPages); - if (! is_null($this->currentPage)) { + if (!is_null($this->currentPage)) { $this->currentPage->setActive(); } diff --git a/src/Navigation/Badge.php b/src/Navigation/Badge.php index ac195cf63..26195904c 100644 --- a/src/Navigation/Badge.php +++ b/src/Navigation/Badge.php @@ -13,7 +13,7 @@ public function toArray() { $value = $this->getValue(); - if (! $this->hasClassProperty('label-', 'bg-')) { + if (!$this->hasClassProperty('label-', 'bg-')) { $this->setHtmlAttribute('class', 'label-primary'); } diff --git a/src/Navigation/Page.php b/src/Navigation/Page.php index 6f4b87235..fb3b95c1e 100644 --- a/src/Navigation/Page.php +++ b/src/Navigation/Page.php @@ -57,7 +57,7 @@ public function getAliasId() */ public function getModelConfiguration() { - if (! $this->hasModel()) { + if (!$this->hasModel()) { return; } @@ -69,7 +69,7 @@ public function getModelConfiguration() */ public function hasModel() { - return ! is_null($this->model) && class_exists($this->model); + return !is_null($this->model) && class_exists($this->model); } /** @@ -113,9 +113,9 @@ public function getUrl() */ public function getAccessLogic() { - if (! is_callable($this->accessLogic)) { + if (!is_callable($this->accessLogic)) { if ($this->hasModel()) { - return function () { + return function() { return $this->getModelConfiguration()->isDisplayable(); }; } @@ -131,13 +131,13 @@ public function getAccessLogic() */ public function render($view = null) { - if ($this->hasChild() && ! $this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) { + if ($this->hasChild() && !$this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) { $this->setHtmlAttribute('class', $class); } $data = $this->toArray(); - if (! is_null($view)) { + if (!is_null($view)) { return view($view, $data)->render(); } diff --git a/src/Providers/AdminServiceProvider.php b/src/Providers/AdminServiceProvider.php index d87434de6..93e2837ad 100644 --- a/src/Providers/AdminServiceProvider.php +++ b/src/Providers/AdminServiceProvider.php @@ -42,17 +42,17 @@ public function register() $this->initializeNavigation(); $this->registerAliases(); - $this->app->singleton('sleeping_owl.widgets', function () { + $this->app->singleton('sleeping_owl.widgets', function() { return new WidgetsRegistry($this->app); }); - $this->app->booted(function () { + $this->app->booted(function() { $this->app['sleeping_owl.widgets']->placeWidgets( $this->app[ViewFactory::class] ); }); - $this->app->booted(function () { + $this->app->booted(function() { $this->registerCustomRoutes(); $this->registerDefaultRoutes(); $this->registerSupportRoutes(); @@ -66,11 +66,11 @@ public function register() protected function registerTemplate() { - $this->app->singleton('assets.packages', function ($app) { + $this->app->singleton('assets.packages', function($app) { return new \KodiCMS\Assets\PackageManager(); }); - $this->app->singleton('sleeping_owl.meta', function ($app) { + $this->app->singleton('sleeping_owl.meta', function($app) { return new Meta( new Assets( $app['assets.packages'] @@ -78,8 +78,8 @@ protected function registerTemplate() ); }); - $this->app->singleton('sleeping_owl.template', function (Application $app) { - if (! class_exists($class = $this->getConfig('template'))) { + $this->app->singleton('sleeping_owl.template', function(Application $app) { + if (!class_exists($class = $this->getConfig('template'))) { throw new TemplateException("Template class [{$class}] not found"); } @@ -108,7 +108,7 @@ protected function getConfig($key) */ protected function getBootstrapPath($path = null) { - if (! is_null($path)) { + if (!is_null($path)) { $path = DIRECTORY_SEPARATOR.$path; } @@ -136,7 +136,7 @@ protected function registerMessages() $this->app[WidgetsRegistryInterface::class]->registerWidget($messageType); } - $this->app->singleton('sleeping_owl.message', function () use ($messageTypes) { + $this->app->singleton('sleeping_owl.message', function() use ($messageTypes) { return new MessageStack($messageTypes); }); } @@ -168,14 +168,14 @@ protected function initializeNavigation() \SleepingOwl\Admin\Navigation\Badge::class ); - $this->app->singleton('sleeping_owl.navigation', function () { + $this->app->singleton('sleeping_owl.navigation', function() { return new Navigation(); }); } protected function registerWysiwyg() { - $this->app->singleton('sleeping_owl.wysiwyg', function () { + $this->app->singleton('sleeping_owl.wysiwyg', function() { return new Manager($this->app); }); } @@ -187,7 +187,7 @@ protected function registerBootstrap() { $directory = $this->getBootstrapPath(); - if (! is_dir($directory)) { + if (!is_dir($directory)) { return; } @@ -197,7 +197,7 @@ protected function registerBootstrap() ->notName('routes.php') ->notName('navigation.php') ->in($directory) - ->sort(function (SplFileInfo $a) { + ->sort(function(SplFileInfo $a) { return $a->getFilename() != 'bootstrap.php'; }); @@ -220,7 +220,7 @@ protected function registerAliases() protected function registerCustomRoutes() { if (file_exists($file = $this->getBootstrapPath('routes.php'))) { - $this->registerRoutes(function (Router $route) use ($file) { + $this->registerRoutes(function(Router $route) use ($file) { require $file; }); } @@ -231,7 +231,7 @@ protected function registerCustomRoutes() */ protected function registerDefaultRoutes() { - $this->registerRoutes(function (Router $router) { + $this->registerRoutes(function(Router $router) { (new ModelRouter($this->app, $router))->register($this->app['sleeping_owl']->getModels()); if (file_exists($routesFile = __DIR__.'/../Http/routes.php')) { @@ -250,7 +250,7 @@ protected function registerSupportRoutes() $domain = config('sleeping_owl.domain', false); $middlewares = collect($this->getConfig('middleware')); - $middlewares = $middlewares->filter(function ($item) { + $middlewares = $middlewares->filter(function($item) { return $item != 'web'; }); $configGroup = collect([ @@ -262,7 +262,7 @@ protected function registerSupportRoutes() $configGroup->put('domain', $domain); } - $this->app['router']->group($configGroup->toArray(), function (Router $route) { + $this->app['router']->group($configGroup->toArray(), function(Router $route) { $route->get('ckeditor/upload/image', [ 'as' => 'admin.ckeditor.upload', 'uses' => 'SleepingOwl\Admin\Http\Controllers\UploadController@ckEditorStore', @@ -290,7 +290,7 @@ protected function registerRoutes(\Closure $callback) $configGroup->put('domain', $domain); } - $this->app['router']->group($configGroup->toArray(), function (Router $route) use ($callback) { + $this->app['router']->group($configGroup->toArray(), function(Router $route) use ($callback) { call_user_func($callback, $route); }); } diff --git a/src/Providers/BreadcrumbsServiceProvider.php b/src/Providers/BreadcrumbsServiceProvider.php index 84cb6987f..a7cf9ca6c 100644 --- a/src/Providers/BreadcrumbsServiceProvider.php +++ b/src/Providers/BreadcrumbsServiceProvider.php @@ -21,7 +21,7 @@ class BreadcrumbsServiceProvider extends ServiceProvider */ public function register() { - $this->app->singleton('sleeping_owl.breadcrumbs', function () { + $this->app->singleton('sleeping_owl.breadcrumbs', function() { return $this->app->make(Breadcrumbs::class); }); } diff --git a/src/Providers/SleepingOwlServiceProvider.php b/src/Providers/SleepingOwlServiceProvider.php index 1f7488d8f..57e0a3973 100644 --- a/src/Providers/SleepingOwlServiceProvider.php +++ b/src/Providers/SleepingOwlServiceProvider.php @@ -51,7 +51,7 @@ protected function registerCore() private function createLocalViewFactory() { $resolver = new EngineResolver(); - $resolver->register('php', function () { + $resolver->register('php', function() { return new PhpEngine(); }); $finder = new FileViewFinder($this->app['files'], [__DIR__.'/../../resources/views']); @@ -64,8 +64,8 @@ private function createLocalViewFactory() protected function registerCommands() { if ($this->app->runningInConsole()) { - if (! class_exists('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider') && - ! $this->app->resolved('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { + if (!class_exists('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider') && + !$this->app->resolved('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { $this->app->register('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'); } @@ -81,7 +81,7 @@ protected function registerCommands() $localViewFactory = $this->createLocalViewFactory(); $this->app->singleton( 'command.sleepingowl.ide.generate', - function ($app) use ($localViewFactory) { + function($app) use ($localViewFactory) { return new \SleepingOwl\Admin\Console\Commands\GeneratorCommand($app['config'], $app['files'], $localViewFactory); } ); diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index cb498606d..c5775717b 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -43,7 +43,7 @@ public function getClass() */ public function setClass($class) { - if (! class_exists($class)) { + if (!class_exists($class)) { throw new RepositoryException("Class {$class} not found."); } @@ -90,7 +90,7 @@ public function getWith() */ public function with($with) { - if (! is_array($with)) { + if (!is_array($with)) { $with = func_get_args(); } diff --git a/src/Repositories/TreeRepository.php b/src/Repositories/TreeRepository.php index 7be3a1d19..08aa712fb 100644 --- a/src/Repositories/TreeRepository.php +++ b/src/Repositories/TreeRepository.php @@ -40,7 +40,7 @@ class TreeRepository extends BaseRepository implements TreeRepositoryInterface */ public function __construct($treeType = null) { - if (! is_null($treeType)) { + if (!is_null($treeType)) { $this->setTreeType($treeType); } } @@ -54,7 +54,7 @@ public function setTreeType($treeType) { $this->treeType = new $treeType($this); - if (! ($this->treeType instanceof TreeTypeInterface)) { + if (!($this->treeType instanceof TreeTypeInterface)) { throw new DisplayTreeException('Tree type class must be instanced of [SleepingOwl\Admin\Contracts\Display\Tree\TreeTypeInterface]'); } } diff --git a/src/Routing/ModelRouter.php b/src/Routing/ModelRouter.php index 8c56b0f9e..b28bbc1a4 100644 --- a/src/Routing/ModelRouter.php +++ b/src/Routing/ModelRouter.php @@ -59,7 +59,7 @@ protected function registerModelPatterns(Collection $aliases) */ protected function registerModelBindings(Collection $aliases) { - $this->router->bind('adminModel', function ($model, Route $route) use ($aliases) { + $this->router->bind('adminModel', function($model, Route $route) use ($aliases) { if (is_null($model = $aliases->get($model))) { throw new ModelNotFoundException(); } @@ -85,7 +85,7 @@ protected function registerModelBindings(Collection $aliases) */ protected function runCustomController(Route $route, $controller, $action) { - $route->uses(function () use ($route, $controller, $action) { + $route->uses(function() use ($route, $controller, $action) { return (new ControllerDispatcher($this->app))->dispatch( $route, $this->app->make($controller), $action ); diff --git a/src/Templates/Assets.php b/src/Templates/Assets.php index 8df1c1f55..6cfe2b5d6 100644 --- a/src/Templates/Assets.php +++ b/src/Templates/Assets.php @@ -37,11 +37,11 @@ public function addJs($handle = false, $src = null, $dependency = null, $footer */ protected function sort($assets) { - $mainAssets = collect($assets)->filter(function (AssetElement $item) { - return ! array_filter($item->getDependency()); + $mainAssets = collect($assets)->filter(function(AssetElement $item) { + return !array_filter($item->getDependency()); }); - $depAssets = collect($assets)->filter(function (AssetElement $item) { + $depAssets = collect($assets)->filter(function(AssetElement $item) { return array_filter($item->getDependency()); }); @@ -69,7 +69,7 @@ protected function insertOn(AssetElement $asset, Collection &$mainAssets, Collec $hasNotDep = null; foreach ($dependency as $dep) { - if (! $mainAssets->has($dep)) { + if (!$mainAssets->has($dep)) { $hasNotDep = $dep; break; } diff --git a/src/Templates/Breadcrumbs.php b/src/Templates/Breadcrumbs.php index ac39a4200..26bf17610 100644 --- a/src/Templates/Breadcrumbs.php +++ b/src/Templates/Breadcrumbs.php @@ -35,7 +35,7 @@ public function renderIfExists($name = null) $name = $params[0]; } - if (! $this->exists($name)) { + if (!$this->exists($name)) { return ''; } @@ -61,7 +61,7 @@ public function renderArray($name, $params = []) */ public function renderIfExistsArray($name, $params = []) { - if (! $this->exists($name)) { + if (!$this->exists($name)) { return ''; } diff --git a/src/Traits/FormElements.php b/src/Traits/FormElements.php index 612a41240..270fcc348 100644 --- a/src/Traits/FormElements.php +++ b/src/Traits/FormElements.php @@ -23,7 +23,7 @@ trait FormElements */ public function initializeElements() { - $this->getElements()->each(function ($element) { + $this->getElements()->each(function($element) { if ($element instanceof Initializable) { $element->initialize(); } @@ -41,7 +41,7 @@ public function getElement($path) foreach ($this->getElements() as $element) { if ($element instanceof ElementsInterface) { - if (! is_null($found = $element->getElement($path))) { + if (!is_null($found = $element->getElement($path))) { return $found; } } @@ -145,7 +145,7 @@ public function afterSave(\Illuminate\Http\Request $request) */ protected function setModelForElements(Model $model) { - $this->getElements()->each(function ($element) use ($model) { + $this->getElements()->each(function($element) use ($model) { $element = $this->getElementContainer($element); if ($element instanceof WithModelInterface) { @@ -163,7 +163,7 @@ protected function setModelForElements(Model $model) */ protected function getValidationRulesFromElements(array $rules = []) { - $this->getElements()->onlyActive()->each(function ($element) use (&$rules) { + $this->getElements()->onlyActive()->each(function($element) use (&$rules) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -181,7 +181,7 @@ protected function getValidationRulesFromElements(array $rules = []) */ protected function getValidationMessagesForElements(array $messages = []) { - $this->getElements()->onlyActive()->each(function ($element) use (&$messages) { + $this->getElements()->onlyActive()->each(function($element) use (&$messages) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -199,7 +199,7 @@ protected function getValidationMessagesForElements(array $messages = []) */ protected function getValidationLabelsForElements(array $labels = []) { - $this->getElements()->onlyActive()->each(function ($element) use (&$labels) { + $this->getElements()->onlyActive()->each(function($element) use (&$labels) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -217,7 +217,7 @@ protected function getValidationLabelsForElements(array $labels = []) */ protected function saveElements(\Illuminate\Http\Request $request) { - $this->getElements()->onlyActive()->each(function ($element) use ($request) { + $this->getElements()->onlyActive()->each(function($element) use ($request) { $element = $this->getElementContainer($element); if ($element instanceof FormElementInterface) { @@ -233,7 +233,7 @@ protected function saveElements(\Illuminate\Http\Request $request) */ protected function afterSaveElements(\Illuminate\Http\Request $request) { - $this->getElements()->onlyActive()->each(function ($element) use ($request) { + $this->getElements()->onlyActive()->each(function($element) use ($request) { $element = $this->getElementContainer($element); if ($element instanceof FormElementInterface) { diff --git a/src/Traits/OrderableModel.php b/src/Traits/OrderableModel.php index abe2ec61f..a3f27012a 100644 --- a/src/Traits/OrderableModel.php +++ b/src/Traits/OrderableModel.php @@ -17,16 +17,16 @@ trait OrderableModel */ protected static function bootOrderableModel() { - static::creating(function (Model $row) { + static::creating(function(Model $row) { $row->updateOrderFieldOnCreate(); }); - static::deleted(function (Model $row) { + static::deleted(function(Model $row) { $row->updateOrderFieldOnDelete(); }); if (in_array("Illuminate\Database\Eloquent\SoftDeletes", trait_uses_recursive(new static()))) { - static::restoring(function (Model $row) { + static::restoring(function(Model $row) { $row->updateOrderFieldOnRestore(); }); } @@ -87,8 +87,8 @@ protected function updateOrderFieldOnCreate() protected function updateOrderFieldOnDelete() { static::orderModel() - ->where($this->getOrderField(), '>', $this->getOrderValue()) - ->decrement($this->getOrderField()); + ->where($this->getOrderField(), '>', $this->getOrderValue()) + ->decrement($this->getOrderField()); } /** diff --git a/src/Traits/SelectOptionsFromModel.php b/src/Traits/SelectOptionsFromModel.php index bf8e0c259..085fc5666 100644 --- a/src/Traits/SelectOptionsFromModel.php +++ b/src/Traits/SelectOptionsFromModel.php @@ -64,7 +64,7 @@ public function setModelForOptions($modelForOptions) $modelForOptions = app($modelForOptions); } - if (! ($modelForOptions instanceof Model)) { + if (!($modelForOptions instanceof Model)) { throw new SelectException('Class must be instanced of Illuminate\Database\Eloquent\Model'); } @@ -121,7 +121,7 @@ public function setDisplay($display) */ public function setFetchColumns($columns) { - if (! is_array($columns)) { + if (!is_array($columns)) { $columns = func_get_args(); } @@ -216,7 +216,7 @@ protected function loadOptions() $options = $repository->getQuery(); - if ($this->isEmptyRelation() && ! is_null($foreignKey = $this->getForeignKey())) { + if ($this->isEmptyRelation() && !is_null($foreignKey = $this->getForeignKey())) { $relation = $this->getModelAttributeKey(); $model = $this->getModel(); @@ -232,7 +232,7 @@ protected function loadOptions() } // call the pre load options query preparer if has be set - if (! is_null($preparer = $this->getLoadOptionsQueryPreparer())) { + if (!is_null($preparer = $this->getLoadOptionsQueryPreparer())) { $options = $preparer($this, $options); } @@ -249,7 +249,7 @@ protected function loadOptions() // iterate for all options and redefine it as // list of KEY and TEXT pair - $options = array_map(function ($opt) use ($key, $makeDisplay) { + $options = array_map(function($opt) use ($key, $makeDisplay) { // get the KEY and make the display text return [data_get($opt, $key), $makeDisplay($opt)]; }, $options); diff --git a/src/Traits/SqlQueryOperators.php b/src/Traits/SqlQueryOperators.php index 74276a43d..9ef3ea6df 100644 --- a/src/Traits/SqlQueryOperators.php +++ b/src/Traits/SqlQueryOperators.php @@ -54,7 +54,7 @@ public function getOperator() */ public function setOperator($operator) { - if (! array_key_exists($operator, $this->sqlOperators)) { + if (!array_key_exists($operator, $this->sqlOperators)) { throw new FilterOperatorException("Operator [$operator] not found"); } @@ -119,13 +119,13 @@ protected function prepareValue($value) break; case 'whereBetween': case 'whereNotBetween': - if (! is_array($value)) { + if (!is_array($value)) { $value = explode(',', $value, 2); } break; case 'whereIn': case 'whereNotIn': - if (! is_array($value)) { + if (!is_array($value)) { $value = explode(',', $value); } break; diff --git a/src/Widgets/WidgetsRegistry.php b/src/Widgets/WidgetsRegistry.php index 36a734843..8211d4e2d 100644 --- a/src/Widgets/WidgetsRegistry.php +++ b/src/Widgets/WidgetsRegistry.php @@ -54,22 +54,22 @@ public function placeWidgets(Factory $factory) } $groupedBlocks = $this->widgets - ->map(function ($class) { + ->map(function($class) { return $this->makeWidget($class); }) - ->filter(function (WidgetInterface $block) { + ->filter(function(WidgetInterface $block) { return $block->active(); }) - ->groupBy(function (WidgetInterface $block) { + ->groupBy(function(WidgetInterface $block) { return $block->template(); }); foreach ($groupedBlocks as $template => $widgets) { - $factory->composer($template, function (View $view) use ($widgets) { + $factory->composer($template, function(View $view) use ($widgets) { $factory = $view->getFactory(); /** @var Collection|WidgetInterface[] $widgets */ - $widgets = $widgets->sortBy(function (WidgetInterface $block) { + $widgets = $widgets->sortBy(function(WidgetInterface $block) { return $block->position(); }); diff --git a/src/Wysiwyg/Manager.php b/src/Wysiwyg/Manager.php index 50e721f7a..48b729998 100644 --- a/src/Wysiwyg/Manager.php +++ b/src/Wysiwyg/Manager.php @@ -83,7 +83,7 @@ public function getFilters() */ public function getEditor($editorId) { - return $this->getFilters()->filter(function (WysiwygEditorInterface $editor) use ($editorId) { + return $this->getFilters()->filter(function(WysiwygEditorInterface $editor) use ($editorId) { return $editor->getId() == $editorId; })->first(); } @@ -100,7 +100,7 @@ public function loadDefaultEditor() */ public function loadEditor($editorId) { - if (! is_null($editor = $this->getEditor($editorId))) { + if (!is_null($editor = $this->getEditor($editorId))) { if ($editor->isUsed()) { return true; } @@ -120,7 +120,7 @@ public function loadEditor($editorId) */ public function applyFilter($editorId, $text) { - if (! is_null($editor = $this->getEditor($editorId))) { + if (!is_null($editor = $this->getEditor($editorId))) { return $editor->applyFilter($text); } From 772a6c4385928908c26152c888a8563ba37862e4 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 21 May 2018 21:55:26 +0000 Subject: [PATCH 002/108] Apply fixes from StyleCI --- src/Admin.php | 2 +- src/AliasBinder.php | 2 +- src/Console/Commands/InstallCommand.php | 8 ++-- src/Console/Commands/UserManagerCommand.php | 4 +- src/Console/Generator.php | 6 +-- src/Console/Installation/Command.php | 8 ++-- src/Display/Column/Control.php | 26 ++++++------ src/Display/Column/Custom.php | 4 +- src/Display/Column/Editable/DateTime.php | 8 ++-- .../Column/Editable/EditableColumn.php | 2 +- .../Column/Filter/BaseColumnFilter.php | 2 +- src/Display/Column/Filter/Range.php | 6 +-- src/Display/Column/Filter/Select.php | 6 +-- src/Display/Column/Image.php | 2 +- src/Display/Column/NamedColumn.php | 8 ++-- src/Display/Column/Order.php | 6 +-- src/Display/Display.php | 6 +-- src/Display/DisplayDatatables.php | 2 +- src/Display/DisplayDatatablesAsync.php | 8 ++-- src/Display/DisplayTab.php | 6 +-- src/Display/DisplayTabbed.php | 12 +++--- src/Display/DisplayTable.php | 6 +-- src/Display/DisplayTabsCollection.php | 6 +-- src/Display/DisplayTree.php | 10 ++--- src/Display/Extension/Actions.php | 6 +-- src/Display/Extension/Apply.php | 2 +- src/Display/Extension/ColumnFilters.php | 8 ++-- src/Display/Extension/Columns.php | 12 +++--- src/Display/Extension/ColumnsTotal.php | 4 +- src/Display/Extension/Filters.php | 8 ++-- src/Display/Extension/Scopes.php | 4 +- src/Display/ExtensionCollection.php | 10 ++--- src/Display/Filter/FilterBase.php | 6 +-- src/Display/Filter/FilterCustom.php | 2 +- src/Display/Filter/FilterField.php | 4 +- src/Display/Filter/FilterRelated.php | 2 +- src/Display/TableColumn.php | 6 +-- src/Form/Buttons/Delete.php | 2 +- src/Form/Buttons/Destroy.php | 2 +- src/Form/Buttons/Restore.php | 2 +- src/Form/Columns/Columns.php | 12 +++--- src/Form/Element/Custom.php | 2 +- src/Form/Element/DateRange.php | 6 +-- src/Form/Element/DateTime.php | 4 +- src/Form/Element/DependentSelect.php | 2 +- src/Form/Element/File.php | 6 +-- src/Form/Element/Image.php | 4 +- src/Form/Element/Images.php | 6 +-- src/Form/Element/MultiSelect.php | 6 +-- src/Form/Element/MultiSelectAjax.php | 12 +++--- src/Form/Element/NamedFormElement.php | 14 +++---- src/Form/Element/Password.php | 10 ++--- src/Form/Element/SelectAjax.php | 4 +- src/Form/Element/Upload.php | 2 +- src/Form/Element/View.php | 2 +- src/Form/Element/Wysiwyg.php | 8 ++-- src/Form/FormButtons.php | 8 ++-- src/Form/FormDefault.php | 18 ++++---- src/Form/FormElement.php | 2 +- src/Form/FormElementsCollection.php | 6 +-- src/Form/FormPanel.php | 8 ++-- src/Http/Controllers/AdminController.php | 42 +++++++++---------- src/Http/Controllers/DisplayController.php | 2 +- .../Controllers/FormElementController.php | 10 ++--- src/Http/Controllers/UploadController.php | 6 +-- src/Http/routes.php | 4 +- src/Model/ModelCollection.php | 4 +- src/Model/ModelConfiguration.php | 12 +++--- src/Model/ModelConfigurationManager.php | 10 ++--- src/Model/SectionModelConfiguration.php | 6 +-- src/Navigation.php | 8 ++-- src/Navigation/Badge.php | 2 +- src/Navigation/Page.php | 12 +++--- src/Providers/AdminServiceProvider.php | 36 ++++++++-------- src/Providers/BreadcrumbsServiceProvider.php | 2 +- src/Providers/SleepingOwlServiceProvider.php | 8 ++-- src/Repositories/BaseRepository.php | 4 +- src/Repositories/TreeRepository.php | 4 +- src/Routing/ModelRouter.php | 4 +- src/Templates/Assets.php | 8 ++-- src/Templates/Breadcrumbs.php | 4 +- src/Traits/FormElements.php | 16 +++---- src/Traits/OrderableModel.php | 6 +-- src/Traits/SelectOptionsFromModel.php | 10 ++--- src/Traits/SqlQueryOperators.php | 6 +-- src/Widgets/WidgetsRegistry.php | 10 ++--- src/Wysiwyg/Manager.php | 6 +-- 87 files changed, 310 insertions(+), 310 deletions(-) diff --git a/src/Admin.php b/src/Admin.php index 689657bc1..b713c2ec1 100644 --- a/src/Admin.php +++ b/src/Admin.php @@ -164,7 +164,7 @@ public function getModel($class) $class = get_class($class); } - if (!$this->hasModel($class)) { + if (! $this->hasModel($class)) { $this->registerModel($class); } diff --git a/src/AliasBinder.php b/src/AliasBinder.php index a4ded9e9b..1c1fe7af9 100644 --- a/src/AliasBinder.php +++ b/src/AliasBinder.php @@ -146,7 +146,7 @@ public function makeClass($alias, array $arguments) */ public function __call($name, $arguments) { - if (!$this->hasAlias($name)) { + if (! $this->hasAlias($name)) { throw new BadMethodCallException($name); } diff --git a/src/Console/Commands/InstallCommand.php b/src/Console/Commands/InstallCommand.php index f77676e56..756e234fd 100644 --- a/src/Console/Commands/InstallCommand.php +++ b/src/Console/Commands/InstallCommand.php @@ -31,11 +31,11 @@ protected function runInstaller() Installation\CreateRoutesFile::class, Installation\CreateSectionServiceProvider::class, Installation\CreatePublicDirectory::class, - ])->map(function($installer) { + ])->map(function ($installer) { return new $installer($this, $this->config); - })->filter(function(Installator $installer) { - return $this->option('force') ? true : !$installer->installed(); - })->each(function(Installator $installer) { + })->filter(function (Installator $installer) { + return $this->option('force') ? true : ! $installer->installed(); + })->each(function (Installator $installer) { $installer->install(); $installer->showInfo(); }); diff --git a/src/Console/Commands/UserManagerCommand.php b/src/Console/Commands/UserManagerCommand.php index 1d974d84b..52d64cf78 100644 --- a/src/Console/Commands/UserManagerCommand.php +++ b/src/Console/Commands/UserManagerCommand.php @@ -86,7 +86,7 @@ protected function createNewUser() return; } - if (!is_null($userClass::where('email', $email)->first())) { + if (! is_null($userClass::where('email', $email)->first())) { $this->error("User with same email [{$email}] exists."); return; @@ -140,7 +140,7 @@ protected function deleteUser() } $confirm = $this->confirm("Are you sure want to delete user with id [{$id}]?", false); - if (!$confirm) { + if (! $confirm) { return; } diff --git a/src/Console/Generator.php b/src/Console/Generator.php index 26c4221f1..1a65a0c52 100644 --- a/src/Console/Generator.php +++ b/src/Console/Generator.php @@ -24,8 +24,8 @@ protected function getAliasesByExtendsNamespace() { $aliases = $this->getValidAliases(); - $aliases = $aliases->filter(function(Alias $item) { - return !collect([ + $aliases = $aliases->filter(function (Alias $item) { + return ! collect([ 'MessageStack', 'AdminSection', 'AdminTemplate', @@ -40,7 +40,7 @@ protected function getAliasesByExtendsNamespace() ])->search($item->getAlias()); }); - return $aliases->groupBy(function(Alias $alias) { + return $aliases->groupBy(function (Alias $alias) { return $alias->getExtendsNamespace(); }); } diff --git a/src/Console/Installation/Command.php b/src/Console/Installation/Command.php index 937425009..8649d07b1 100644 --- a/src/Console/Installation/Command.php +++ b/src/Console/Installation/Command.php @@ -29,11 +29,11 @@ abstract class Command extends ConsoleCommand */ public function fire(Filesystem $files) { - if (!defined('SLEEPINGOWL_STUB_PATH')) { + if (! defined('SLEEPINGOWL_STUB_PATH')) { define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); } - if (!$this->confirmToProceed('SleepingOwl Admin')) { + if (! $this->confirmToProceed('SleepingOwl Admin')) { return; } @@ -55,11 +55,11 @@ public function fire(Filesystem $files) */ public function handle(Filesystem $files) { - if (!defined('SLEEPINGOWL_STUB_PATH')) { + if (! defined('SLEEPINGOWL_STUB_PATH')) { define('SLEEPINGOWL_STUB_PATH', __DIR__.'/stubs'); } - if (!$this->confirmToProceed('SleepingOwl Admin')) { + if (! $this->confirmToProceed('SleepingOwl Admin')) { return; } diff --git a/src/Display/Column/Control.php b/src/Display/Column/Control.php index 834f7ffa0..9480da8f8 100644 --- a/src/Display/Column/Control.php +++ b/src/Display/Column/Control.php @@ -64,20 +64,20 @@ public function initialize() { parent::initialize(); - $this->buttons->put('edit', $button = new ControlLink(function(Model $model) { + $this->buttons->put('edit', $button = new ControlLink(function (Model $model) { return $this->getModelConfiguration()->getEditUrl($model->getKey()); }, trans('sleeping_owl::lang.table.edit'), 100)); $button->hideText(); - $button->setCondition(function() { + $button->setCondition(function () { return $this->isEditable(); }); $button->setIcon('fa fa-pencil'); $button->setHtmlAttribute('class', 'btn-primary'); - $this->buttons->put('delete', $button = new ControlButton(function(Model $model) { + $this->buttons->put('delete', $button = new ControlButton(function (Model $model) { return $this->getModelConfiguration()->getDeleteUrl($model->getKey()); }, trans('sleeping_owl::lang.table.delete'), 200)); - $button->setCondition(function() { + $button->setCondition(function () { return $this->isDeletable(); }); @@ -86,10 +86,10 @@ public function initialize() $button->setIcon('fa fa-trash'); $button->setHtmlAttribute('class', 'btn-danger btn-delete'); - $this->buttons->put('destroy', $button = new ControlButton(function(Model $model) { + $this->buttons->put('destroy', $button = new ControlButton(function (Model $model) { return $this->getModelConfiguration()->getDestroyUrl($model->getKey()); }, trans('sleeping_owl::lang.table.destroy'), 300)); - $button->setCondition(function() { + $button->setCondition(function () { return $this->isDestroyable(); }); @@ -98,10 +98,10 @@ public function initialize() $button->setIcon('fa fa-trash'); $button->setHtmlAttribute('class', 'btn-danger btn-destroy'); - $this->buttons->put('restore', $button = new ControlButton(function(Model $model) { + $this->buttons->put('restore', $button = new ControlButton(function (Model $model) { return $this->getModelConfiguration()->getRestoreUrl($model->getKey()); }, trans('sleeping_owl::lang.table.restore'), 400)); - $button->setCondition(function() { + $button->setCondition(function () { return $this->isRestorable(); }); $button->hideText(); @@ -205,7 +205,7 @@ protected function isEditable() return $this->editable && - !$this->isTrashed() + ! $this->isTrashed() && $this->getModelConfiguration()->isEditable( $this->getModel() @@ -222,7 +222,7 @@ protected function isDeletable() return $this->deletable && - !$this->isTrashed() + ! $this->isTrashed() && $this->getModelConfiguration()->isDeletable( $this->getModel() @@ -282,13 +282,13 @@ public function toArray() { return parent::toArray() + [ 'buttons' => $this->buttons - ->each(function(ControlButtonInterface $button) { + ->each(function (ControlButtonInterface $button) { $button->setModel($this->getModel()); }) - ->filter(function(ControlButtonInterface $button) { + ->filter(function (ControlButtonInterface $button) { return $button->isActive(); }) - ->sortBy(function(ControlButtonInterface $button) { + ->sortBy(function (ControlButtonInterface $button) { return $button->getPosition(); }), ]; diff --git a/src/Display/Column/Custom.php b/src/Display/Column/Custom.php index eee9f75c9..6835dcf95 100644 --- a/src/Display/Column/Custom.php +++ b/src/Display/Column/Custom.php @@ -32,7 +32,7 @@ class Custom extends TableColumn public function __construct($label = null, Closure $callback = null) { parent::__construct($label); - if (!is_null($callback)) { + if (! is_null($callback)) { $this->setCallback($callback); } } @@ -66,7 +66,7 @@ public function setCallback(Closure $callback) */ public function getModelValue() { - if (!is_callable($callback = $this->getCallback())) { + if (! is_callable($callback = $this->getCallback())) { throw new \Exception('Invalid custom column callback'); } diff --git a/src/Display/Column/Editable/DateTime.php b/src/Display/Column/Editable/DateTime.php index 7e13a677e..4eec46c1e 100644 --- a/src/Display/Column/Editable/DateTime.php +++ b/src/Display/Column/Editable/DateTime.php @@ -76,8 +76,8 @@ public function toArray() */ protected function getFormatedDate($date) { - if (!is_null($date)) { - if (!$date instanceof Carbon) { + if (! is_null($date)) { + if (! $date instanceof Carbon) { $date = Carbon::parse($date); } @@ -93,7 +93,7 @@ protected function getFormatedDate($date) public function getValueFromModel() { $value = parent::getValueFromModel(); - if (!empty($value)) { + if (! empty($value)) { return $this->parseValue($value); } } @@ -125,7 +125,7 @@ public function setSeconds($seconds) */ public function setModelAttribute($value) { - $value = !empty($value) + $value = ! empty($value) ? Carbon::createFromFormat($this->getPickerFormat(), $value, $this->getTimezone()) ->timezone(config('app.timezone'))->format($this->getFormat()) : null; diff --git a/src/Display/Column/Editable/EditableColumn.php b/src/Display/Column/Editable/EditableColumn.php index fe93b3802..827dcafd9 100644 --- a/src/Display/Column/Editable/EditableColumn.php +++ b/src/Display/Column/Editable/EditableColumn.php @@ -70,7 +70,7 @@ public function setTitle($title) */ public function getUrl() { - if (!$this->url) { + if (! $this->url) { return request()->url(); } diff --git a/src/Display/Column/Filter/BaseColumnFilter.php b/src/Display/Column/Filter/BaseColumnFilter.php index 279e7f833..16bad2c1c 100644 --- a/src/Display/Column/Filter/BaseColumnFilter.php +++ b/src/Display/Column/Filter/BaseColumnFilter.php @@ -135,7 +135,7 @@ public function apply(ColumnInterface $column, Builder $query, $queryString, $qu $fieldName = array_pop($parts); $relationName = implode('.', $parts); - $query->whereHas($relationName, function($q) use ($queryString, $fieldName) { + $query->whereHas($relationName, function ($q) use ($queryString, $fieldName) { $this->buildQuery($q, $fieldName, $queryString); }); } else { diff --git a/src/Display/Column/Filter/Range.php b/src/Display/Column/Filter/Range.php index ec9074ef4..d2c165a61 100644 --- a/src/Display/Column/Filter/Range.php +++ b/src/Display/Column/Filter/Range.php @@ -104,15 +104,15 @@ public function parseValue($range) $from = $this->from->parseValue($from); $to = $this->to->parseValue($to); - if (!empty($from) && !empty($to)) { + if (! empty($from) && ! empty($to)) { $this->setOperator('between'); return [$from, $to]; - } elseif (!empty($from)) { + } elseif (! empty($from)) { $this->setOperator('greater_or_equal'); return $from; - } elseif (!empty($to)) { + } elseif (! empty($to)) { $this->setOperator('less_or_equal'); return $to; diff --git a/src/Display/Column/Filter/Select.php b/src/Display/Column/Filter/Select.php index efc94425a..890061396 100644 --- a/src/Display/Column/Filter/Select.php +++ b/src/Display/Column/Filter/Select.php @@ -52,7 +52,7 @@ public function __construct($options = null, $title = null) $this->setModelForOptions($options); } - if (!is_null($title)) { + if (! is_null($title)) { $this->setDisplay($title); } } @@ -77,7 +77,7 @@ public function initialize() if ($this->multiple) { $this->setHtmlAttribute('multiple', 'multiple'); - if (!in_array($this->operator, ['in', 'not_in'])) { + if (! in_array($this->operator, ['in', 'not_in'])) { $this->setOperator('in'); } } else { @@ -121,7 +121,7 @@ public function setModel($model) */ public function getOptions() { - if (!is_null($this->getModelForOptions()) && !is_null($this->getDisplay())) { + if (! is_null($this->getModelForOptions()) && ! is_null($this->getDisplay())) { $this->setOptions( $this->loadOptions() ); diff --git a/src/Display/Column/Image.php b/src/Display/Column/Image.php index bb29483af..252141f64 100644 --- a/src/Display/Column/Image.php +++ b/src/Display/Column/Image.php @@ -40,7 +40,7 @@ public function setImageWidth($width) public function toArray() { $value = $this->getModelValue(); - if (!empty($value) && (strpos($value, '://') === false)) { + if (! empty($value) && (strpos($value, '://') === false)) { $value = asset($value); } diff --git a/src/Display/Column/NamedColumn.php b/src/Display/Column/NamedColumn.php index 6599d2f5f..7b51720e2 100644 --- a/src/Display/Column/NamedColumn.php +++ b/src/Display/Column/NamedColumn.php @@ -104,8 +104,8 @@ public function getModelSmallValue() */ public function setOrderable($orderable = true) { - if ($orderable !== false && !$orderable instanceof OrderByClauseInterface) { - if (!is_string($orderable) && !$orderable instanceof Closure) { + if ($orderable !== false && ! $orderable instanceof OrderByClauseInterface) { + if (! is_string($orderable) && ! $orderable instanceof Closure) { $orderable = $this->getName(); } } @@ -173,11 +173,11 @@ protected function getValueFromObject($instance, $name) if ($instance === null) { $instance = collect(); } - } elseif (!is_null($instance)) { + } elseif (! is_null($instance)) { $instance = $instance->getAttribute($part); } - if (!empty($parts) && !is_null($instance)) { + if (! empty($parts) && ! is_null($instance)) { return $this->getValueFromObject($instance, implode('.', $parts)); } diff --git a/src/Display/Column/Order.php b/src/Display/Column/Order.php index 1e3636b8f..58e8537c3 100644 --- a/src/Display/Column/Order.php +++ b/src/Display/Column/Order.php @@ -28,7 +28,7 @@ class Order extends TableColumn implements WithRoutesInterface public static function registerRoutes(Router $router) { $routeName = 'admin.display.column.move-up'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/{adminModelId}/up', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayColumnController@orderUp', @@ -36,7 +36,7 @@ public static function registerRoutes(Router $router) } $routeName = 'admin.display.column.move-down'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/{adminModelId}/down', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayColumnController@orderDown', @@ -56,7 +56,7 @@ public function __construct() */ public function getModel() { - if (!in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { + if (! in_array(OrderableModel::class, trait_uses_recursive($class = get_class($this->model)))) { throw new \Exception("Model [$class] should uses trait [SleepingOwl\\Admin\\Traits\\OrderableModel]"); } diff --git a/src/Display/Display.php b/src/Display/Display.php index 611392c31..8d4b20cb0 100644 --- a/src/Display/Display.php +++ b/src/Display/Display.php @@ -192,7 +192,7 @@ public function getTitle() $this->title, ]; - $this->getExtensions()->each(function(DisplayExtensionInterface $extension) use (&$titles) { + $this->getExtensions()->each(function (DisplayExtensionInterface $extension) use (&$titles) { if (method_exists($extension, $method = 'getTitle')) { $titles[] = call_user_func([$extension, $method]); } @@ -240,7 +240,7 @@ public function render() foreach ($blocks as $block => $data) { foreach ($data as $html) { - if (!empty($html)) { + if (! empty($html)) { $view->getFactory()->startSection($block); echo $html; $view->getFactory()->yieldSection(); @@ -291,7 +291,7 @@ protected function getModelConfiguration() protected function makeRepository() { $repository = app($this->repositoryClass); - if (!($repository instanceof RepositoryInterface)) { + if (! ($repository instanceof RepositoryInterface)) { throw new \Exception('Repository class must be instanced of [RepositoryInterface]'); } diff --git a/src/Display/DisplayDatatables.php b/src/Display/DisplayDatatables.php index 9708bfd87..0774dee2d 100644 --- a/src/Display/DisplayDatatables.php +++ b/src/Display/DisplayDatatables.php @@ -88,7 +88,7 @@ public function getOrder() */ public function setOrder($order) { - if (!is_array($order)) { + if (! is_array($order)) { $order = func_get_args(); } diff --git a/src/Display/DisplayDatatablesAsync.php b/src/Display/DisplayDatatablesAsync.php index 6cb68e42a..751f30b7d 100644 --- a/src/Display/DisplayDatatablesAsync.php +++ b/src/Display/DisplayDatatablesAsync.php @@ -26,7 +26,7 @@ class DisplayDatatablesAsync extends DisplayDatatables implements WithRoutesInte public static function registerRoutes(Router $router) { $routeName = 'admin.display.async'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->get('{adminModel}/async/{adminDisplayName?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayController@async', @@ -34,7 +34,7 @@ public static function registerRoutes(Router $router) } $routeName = 'admin.display.async.inlineEdit'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/async/{adminDisplayName?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\AdminController@inlineEdit', @@ -203,7 +203,7 @@ public function renderAsync(\Illuminate\Http\Request $request) $totalCount = $query->count(); $filteredCount = 0; - if (!is_null($this->distinct)) { + if (! is_null($this->distinct)) { $filteredCount = $query->distinct()->count($this->getDistinct()); } @@ -270,7 +270,7 @@ protected function applySearch(Builder $query, \Illuminate\Http\Request $request return; } - $query->where(function(Builder $query) use ($search) { + $query->where(function (Builder $query) use ($search) { $columns = $this->getColumns()->all(); foreach ($columns as $column) { diff --git a/src/Display/DisplayTab.php b/src/Display/DisplayTab.php index 2c0b2e29b..91d75844a 100644 --- a/src/Display/DisplayTab.php +++ b/src/Display/DisplayTab.php @@ -75,15 +75,15 @@ public function __construct(Renderable $content, $label = null, $icon = null, $b { $this->content = $content; - if (!is_null($label)) { + if (! is_null($label)) { $this->setLabel($label); } - if (!is_null($icon)) { + if (! is_null($icon)) { $this->setIcon($icon); } - if (!is_null($badge)) { + if (! is_null($badge)) { $this->setBadge($badge); } diff --git a/src/Display/DisplayTabbed.php b/src/Display/DisplayTabbed.php index 552c860a1..e4f191a82 100644 --- a/src/Display/DisplayTabbed.php +++ b/src/Display/DisplayTabbed.php @@ -67,7 +67,7 @@ public function initialize() } } - $activeTabs = $this->getTabs()->filter(function(TabInterface $tab) { + $activeTabs = $this->getTabs()->filter(function (TabInterface $tab) { return $tab->isActive(); })->count(); @@ -95,7 +95,7 @@ public function getModel() */ public function setModelClass($class) { - $this->getTabs()->each(function(TabInterface $tab) use ($class) { + $this->getTabs()->each(function (TabInterface $tab) use ($class) { if ($tab instanceof DisplayInterface) { $tab->setModelClass($class); } @@ -179,7 +179,7 @@ public function addElement(TabInterface $element) */ public function setAction($action) { - $this->getTabs()->each(function(TabInterface $tab) use ($action) { + $this->getTabs()->each(function (TabInterface $tab) use ($action) { if ($tab instanceof FormInterface) { $tab->setAction($action); } @@ -195,7 +195,7 @@ public function setAction($action) */ public function setId($id) { - $this->getTabs()->each(function(TabInterface $tab) use ($id) { + $this->getTabs()->each(function (TabInterface $tab) use ($id) { if ($tab instanceof FormInterface) { $tab->setId($id); } @@ -212,7 +212,7 @@ public function setId($id) */ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $model = null) { - $this->getTabs()->each(function($tab) use ($request, $model) { + $this->getTabs()->each(function ($tab) use ($request, $model) { $tabId = $request->get('sleeping_owl_tab_id'); if ($tab instanceof FormInterface && $tab->getName() == $tabId) { @@ -229,7 +229,7 @@ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurati */ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $model = null) { - $this->getTabs()->each(function(TabInterface $tab) use ($request, $model) { + $this->getTabs()->each(function (TabInterface $tab) use ($request, $model) { $tabId = $request->get('sleeping_owl_tab_id'); if ($tab instanceof FormInterface && $tab->getName() == $tabId) { diff --git a/src/Display/DisplayTable.php b/src/Display/DisplayTable.php index 18bb2bbd8..28d1cb463 100644 --- a/src/Display/DisplayTable.php +++ b/src/Display/DisplayTable.php @@ -73,7 +73,7 @@ public function initialize() parent::initialize(); if ($this->getModelConfiguration()->isRestorableModel()) { - $this->setApply(function(Builder $q) { + $this->setApply(function (Builder $q) { return $q->withTrashed(); }); } @@ -195,11 +195,11 @@ public function toArray() */ public function getCollection() { - if (!$this->isInitialized()) { + if (! $this->isInitialized()) { throw new \Exception('Display is not initialized'); } - if (!is_null($this->collection)) { + if (! is_null($this->collection)) { return $this->collection; } diff --git a/src/Display/DisplayTabsCollection.php b/src/Display/DisplayTabsCollection.php index 56ce4a3bf..c27057deb 100644 --- a/src/Display/DisplayTabsCollection.php +++ b/src/Display/DisplayTabsCollection.php @@ -13,11 +13,11 @@ class DisplayTabsCollection extends FormElementsCollection */ public function onlyActive() { - return $this->filter(function(TabInterface $tab) { + return $this->filter(function (TabInterface $tab) { $element = $tab->getContent(); if ($element instanceof FormElementInterface) { - return !$element->isReadonly(); + return ! $element->isReadonly(); } return true; @@ -29,7 +29,7 @@ public function onlyActive() */ public function onlyVisible() { - return $this->filter(function(TabInterface $tab) { + return $this->filter(function (TabInterface $tab) { return $tab->isVisible(); }); } diff --git a/src/Display/DisplayTree.php b/src/Display/DisplayTree.php index 2083447f6..8273a1e9a 100644 --- a/src/Display/DisplayTree.php +++ b/src/Display/DisplayTree.php @@ -23,7 +23,7 @@ class DisplayTree extends Display implements WithRoutesInterface public static function registerRoutes(Router $router) { $routeName = 'admin.display.tree.reorder'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/reorder', ['as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\DisplayController@treeReorder']); } @@ -116,7 +116,7 @@ public function initialize() if ($this->getParentField()) { $repository = $repository->setParentField($this->getParentField()); } - if (!is_null($this->treeType)) { + if (! is_null($this->treeType)) { $repository->setTreeType($this->treeType); } @@ -338,11 +338,11 @@ protected function getModelConfiguration() */ public function getCollection() { - if (!$this->isInitialized()) { + if (! $this->isInitialized()) { throw new \Exception('Display is not initialized'); } - if (!is_null($this->collection)) { + if (! is_null($this->collection)) { return $this->collection; } @@ -373,7 +373,7 @@ protected function makeRepository() { $repository = parent::makeRepository(); - if (!($repository instanceof TreeRepositoryInterface)) { + if (! ($repository instanceof TreeRepositoryInterface)) { throw new \Exception('Repository class must be instanced of [TreeRepositoryInterface]'); } diff --git a/src/Display/Extension/Actions.php b/src/Display/Extension/Actions.php index fc303890a..26e67e3ec 100644 --- a/src/Display/Extension/Actions.php +++ b/src/Display/Extension/Actions.php @@ -49,7 +49,7 @@ public function clear() */ public function set($actions) { - if (!is_array($actions)) { + if (! is_array($actions)) { $actions = func_get_args(); } @@ -145,13 +145,13 @@ public function initialize() return; } - $this->all()->each(function(ActionInterface $action) { + $this->all()->each(function (ActionInterface $action) { $action->initialize(); }); $this->setHtmlAttribute('data-type', 'display-actions'); - if (!$this->hasHtmlAttribute('class')) { + if (! $this->hasHtmlAttribute('class')) { $this->setHtmlAttribute('class', 'panel-footer'); } } diff --git a/src/Display/Extension/Apply.php b/src/Display/Extension/Apply.php index 937b877aa..124332b86 100644 --- a/src/Display/Extension/Apply.php +++ b/src/Display/Extension/Apply.php @@ -26,7 +26,7 @@ public function all() */ public function set($applies) { - if (!is_array($applies)) { + if (! is_array($applies)) { $applies = func_get_args(); } diff --git a/src/Display/Extension/ColumnFilters.php b/src/Display/Extension/ColumnFilters.php index be8f0678f..8bd670554 100644 --- a/src/Display/Extension/ColumnFilters.php +++ b/src/Display/Extension/ColumnFilters.php @@ -35,7 +35,7 @@ class ColumnFilters extends Extension implements Initializable, Placable */ public function set($columnFilters) { - if (!is_array($columnFilters)) { + if (! is_array($columnFilters)) { $columnFilters = func_get_args(); } @@ -192,13 +192,13 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $display = $this->getDisplay(); - if (!$display->getExtensions()->has('columns')) { + if (! $display->getExtensions()->has('columns')) { return; } $columns = $display->getColumns()->all(); - if (!is_int(key($search))) { + if (! is_int(key($search))) { $search = [$search]; } @@ -235,7 +235,7 @@ protected function validNumberOfFilters() protected function prepareView() { - if (!in_array($this->getPlacement(), ['table.footer', 'table.header']) && $this->view == 'display.extensions.columns_filters_table') { + if (! in_array($this->getPlacement(), ['table.footer', 'table.header']) && $this->view == 'display.extensions.columns_filters_table') { $this->view = 'display.extensions.columns_filters'; $this->setHtmlAttribute('class', 'table table-default'); } diff --git a/src/Display/Extension/Columns.php b/src/Display/Extension/Columns.php index 2f9f37ffb..cb4963e95 100644 --- a/src/Display/Extension/Columns.php +++ b/src/Display/Extension/Columns.php @@ -91,10 +91,10 @@ public function disableControls() $this->controlActive = false; if ($this->isInitialize()) { - $this->columns = $this->columns->filter(function($column) { + $this->columns = $this->columns->filter(function ($column) { $class = get_class($this->getControlColumn()); - return !($column instanceof $class); + return ! ($column instanceof $class); }); } @@ -116,7 +116,7 @@ public function all() */ public function set($columns) { - if (!is_array($columns)) { + if (! is_array($columns)) { $columns = func_get_args(); } @@ -162,7 +162,7 @@ public function toArray() public function initialize() { - $this->all()->each(function(ColumnInterface $column) { + $this->all()->each(function (ColumnInterface $column) { $column->initialize(); }); @@ -204,7 +204,7 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $columns = $this->all(); - if (!is_int(key($orders))) { + if (! is_int(key($orders))) { $orders = [$orders]; } @@ -212,7 +212,7 @@ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) $columnIndex = array_get($order, 'column'); $direction = array_get($order, 'dir', 'asc'); - if (!$columnIndex && $columnIndex !== '0') { + if (! $columnIndex && $columnIndex !== '0') { continue; } diff --git a/src/Display/Extension/ColumnsTotal.php b/src/Display/Extension/ColumnsTotal.php index a5faa75ce..ff017c742 100644 --- a/src/Display/Extension/ColumnsTotal.php +++ b/src/Display/Extension/ColumnsTotal.php @@ -35,8 +35,8 @@ public function __construct() public function set(array $elements, $columnsNumber = 0) { - array_map(function($element) { - if (!is_object($element)) { + array_map(function ($element) { + if (! is_object($element)) { $element = Element::create($element); } $this->elements->push($element); diff --git a/src/Display/Extension/Filters.php b/src/Display/Extension/Filters.php index d9b2306aa..90cc4f9f6 100644 --- a/src/Display/Extension/Filters.php +++ b/src/Display/Extension/Filters.php @@ -41,7 +41,7 @@ public function clear() */ public function set($filters) { - if (!is_array($filters)) { + if (! is_array($filters)) { $filters = func_get_args(); } @@ -79,7 +79,7 @@ public function push(FilterInterface $filter) */ public function getActive() { - return $this->filters->filter(function(FilterInterface $filter) { + return $this->filters->filter(function (FilterInterface $filter) { return $filter->isActive(); }); } @@ -125,7 +125,7 @@ public function toArray() */ public function modifyQuery(Builder $query) { - $this->getActive()->each(function(FilterInterface $filter) use ($query) { + $this->getActive()->each(function (FilterInterface $filter) use ($query) { $filter->apply($query); }); } @@ -135,7 +135,7 @@ public function modifyQuery(Builder $query) */ public function initialize() { - $this->filters->each(function(FilterInterface $filter) { + $this->filters->each(function (FilterInterface $filter) { $filter->initialize(); }); } diff --git a/src/Display/Extension/Scopes.php b/src/Display/Extension/Scopes.php index a84ea4698..fdb3bd506 100644 --- a/src/Display/Extension/Scopes.php +++ b/src/Display/Extension/Scopes.php @@ -43,7 +43,7 @@ public function set($scopes) */ public function push($scope) { - if (!is_array($scope)) { + if (! is_array($scope)) { $scope = func_get_args(); } @@ -70,7 +70,7 @@ public function toArray() public function modifyQuery(Builder $query) { foreach ($this->scopes as $scope) { - if (!is_null($scope)) { + if (! is_null($scope)) { if (is_array($scope)) { $method = array_shift($scope); $params = $scope; diff --git a/src/Display/ExtensionCollection.php b/src/Display/ExtensionCollection.php index 24d6f7b71..1d47baa4d 100644 --- a/src/Display/ExtensionCollection.php +++ b/src/Display/ExtensionCollection.php @@ -15,7 +15,7 @@ class ExtensionCollection extends Collection */ public function placable() { - return $this->filter(function(DisplayExtensionInterface $extension) { + return $this->filter(function (DisplayExtensionInterface $extension) { return $extension instanceof Placable; }); } @@ -42,7 +42,7 @@ public function placableBlocks() */ public function renderable() { - return $this->filter(function(DisplayExtensionInterface $extension) { + return $this->filter(function (DisplayExtensionInterface $extension) { return $extension instanceof Renderable; }); } @@ -52,7 +52,7 @@ public function renderable() */ public function sortByOrder() { - return $this->sortBy(function(DisplayExtensionInterface $extension) { + return $this->sortBy(function (DisplayExtensionInterface $extension) { return $extension->getOrder(); }); } @@ -62,7 +62,7 @@ public function sortByOrder() */ public function initialize() { - $this->each(function(DisplayExtensionInterface $extension) { + $this->each(function (DisplayExtensionInterface $extension) { if ($extension instanceof Initializable) { $extension->initialize(); } @@ -76,7 +76,7 @@ public function initialize() */ public function modifyQuery(\Illuminate\Database\Eloquent\Builder $query) { - $this->each(function(DisplayExtensionInterface $extension) use ($query) { + $this->each(function (DisplayExtensionInterface $extension) use ($query) { $extension->modifyQuery($query); }); diff --git a/src/Display/Filter/FilterBase.php b/src/Display/Filter/FilterBase.php index d614c3427..988291b6c 100644 --- a/src/Display/Filter/FilterBase.php +++ b/src/Display/Filter/FilterBase.php @@ -35,7 +35,7 @@ public function __construct($name, $title = null) { $this->setName($name); - if (!is_null($title)) { + if (! is_null($title)) { $this->setTitle($title); } } @@ -77,7 +77,7 @@ public function setName($name) */ public function getAlias() { - if (!$this->alias) { + if (! $this->alias) { return $this->getName(); } @@ -149,6 +149,6 @@ public function setValue($value) */ public function isActive() { - return !is_null($this->getValue()); + return ! is_null($this->getValue()); } } diff --git a/src/Display/Filter/FilterCustom.php b/src/Display/Filter/FilterCustom.php index a9bda0498..9bf97347f 100644 --- a/src/Display/Filter/FilterCustom.php +++ b/src/Display/Filter/FilterCustom.php @@ -21,7 +21,7 @@ public function __construct($name, $title = null, Closure $callback = null) { parent::__construct($name, $title); - if (!is_null($callback)) { + if (! is_null($callback)) { $this->setCallback($callback); } } diff --git a/src/Display/Filter/FilterField.php b/src/Display/Filter/FilterField.php index 29ea6ce98..1129b0d35 100644 --- a/src/Display/Filter/FilterField.php +++ b/src/Display/Filter/FilterField.php @@ -38,8 +38,8 @@ public function apply(Builder $query) $relationName = implode('.', $parts); } - if (!is_null($relationName)) { - $query->whereHas($relationName, function($q) use ($name, $value) { + if (! is_null($relationName)) { + $query->whereHas($relationName, function ($q) use ($name, $value) { $this->buildQuery($q, $name, $value); }); } else { diff --git a/src/Display/Filter/FilterRelated.php b/src/Display/Filter/FilterRelated.php index 5e984e2ba..46b570545 100644 --- a/src/Display/Filter/FilterRelated.php +++ b/src/Display/Filter/FilterRelated.php @@ -53,7 +53,7 @@ public function getModel() */ public function setModel($model) { - if (!class_exists($model)) { + if (! class_exists($model)) { throw new Exception("Class model [$model] not found"); } diff --git a/src/Display/TableColumn.php b/src/Display/TableColumn.php index 233a06405..ab88bdda9 100644 --- a/src/Display/TableColumn.php +++ b/src/Display/TableColumn.php @@ -79,7 +79,7 @@ public function __construct($label = null) { $this->header = app(TableHeaderColumnInterface::class); - if (!is_null($label)) { + if (! is_null($label)) { $this->setLabel($label); } @@ -274,7 +274,7 @@ public function setOrderable($orderable) $orderable = new OrderByClause($orderable); } - if ($orderable !== false && !$orderable instanceof OrderByClauseInterface) { + if ($orderable !== false && ! $orderable instanceof OrderByClauseInterface) { throw new \InvalidArgumentException('Argument must be instance of SleepingOwl\Admin\Contracts\Display\OrderByClauseInterface interface'); } @@ -309,7 +309,7 @@ public function isOrderable() */ public function orderBy(Builder $query, $direction) { - if (!$this->isOrderable()) { + if (! $this->isOrderable()) { throw new \InvalidArgumentException('Argument must be instance of SleepingOwl\Admin\Contracts\Display\OrderByClauseInterface interface'); } diff --git a/src/Form/Buttons/Delete.php b/src/Form/Buttons/Delete.php index b6b6deb58..49c695972 100644 --- a/src/Form/Buttons/Delete.php +++ b/src/Form/Buttons/Delete.php @@ -41,7 +41,7 @@ public function canShow() return false; } - $this->show = !$this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); + $this->show = ! $this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); return parent::canShow(); } diff --git a/src/Form/Buttons/Destroy.php b/src/Form/Buttons/Destroy.php index 19e789933..29164da44 100644 --- a/src/Form/Buttons/Destroy.php +++ b/src/Form/Buttons/Destroy.php @@ -36,7 +36,7 @@ public function initialize() */ public function canShow() { - if (is_null($this->getModel()->getKey()) || !$this->show) { + if (is_null($this->getModel()->getKey()) || ! $this->show) { return false; } diff --git a/src/Form/Buttons/Restore.php b/src/Form/Buttons/Restore.php index 596305487..e748a9301 100644 --- a/src/Form/Buttons/Restore.php +++ b/src/Form/Buttons/Restore.php @@ -38,7 +38,7 @@ public function initialize() */ public function canShow() { - if (is_null($this->getModel()->getKey()) || !$this->show) { + if (is_null($this->getModel()->getKey()) || ! $this->show) { return false; } diff --git a/src/Form/Columns/Columns.php b/src/Form/Columns/Columns.php index 405c980f8..9ab2904da 100644 --- a/src/Form/Columns/Columns.php +++ b/src/Form/Columns/Columns.php @@ -70,7 +70,7 @@ public function addElement($element, $width = null) $element = new Column($element); } - if (!($element instanceof ColumnInterface)) { + if (! ($element instanceof ColumnInterface)) { throw new \Exception('Column should be instance of ColumnInterface'); } @@ -85,16 +85,16 @@ public function initialize() { $this->setHtmlAttribute('class', 'row'); - $count = $this->getElements()->filter(function(ColumnInterface $column) { + $count = $this->getElements()->filter(function (ColumnInterface $column) { return $column->getWidth() === 0; })->count(); - $width = $this->maxWidth - $this->getElements()->sum(function(ColumnInterface $column) { + $width = $this->maxWidth - $this->getElements()->sum(function (ColumnInterface $column) { return $column->getWidth(); }); - $this->getElements()->each(function(ColumnInterface $column) use ($width, $count) { - if (!$column->getWidth()) { + $this->getElements()->each(function (ColumnInterface $column) use ($width, $count) { + if (! $column->getWidth()) { $column->setWidth(floor($width / $count)); } }); @@ -134,7 +134,7 @@ public function getSize() */ public function setSize($size) { - $this->getColumns()->each(function(ColumnInterface $column) use ($size) { + $this->getColumns()->each(function (ColumnInterface $column) use ($size) { $column->setSize($size); }); } diff --git a/src/Form/Element/Custom.php b/src/Form/Element/Custom.php index 2f7cfc61c..fca9f582b 100644 --- a/src/Form/Element/Custom.php +++ b/src/Form/Element/Custom.php @@ -26,7 +26,7 @@ class Custom extends FormElement */ public function __construct(Closure $callback = null) { - if (!is_null($callback)) { + if (! is_null($callback)) { $this->setCallback($callback); } diff --git a/src/Form/Element/DateRange.php b/src/Form/Element/DateRange.php index ee4097434..7c3e8fa1c 100644 --- a/src/Form/Element/DateRange.php +++ b/src/Form/Element/DateRange.php @@ -31,7 +31,7 @@ class DateRange extends Date */ public function getDefaultFrom() { - if (!$this->defaultFrom) { + if (! $this->defaultFrom) { $this->defaultFrom = Carbon::now(); } @@ -57,7 +57,7 @@ public function setDefaultFrom($defaultFrom) */ public function getDefaultTo() { - if (!$this->defaultTo) { + if (! $this->defaultTo) { $this->defaultTo = Carbon::now(); } @@ -85,7 +85,7 @@ public function setDefaultTo($defaultTo) */ public function setModelAttribute($value) { - $value = !empty($value) ? array_map(function($date) { + $value = ! empty($value) ? array_map(function ($date) { return Carbon::createFromFormat($this->getPickerFormat(), $date); }, explode('::', $value)) : null; diff --git a/src/Form/Element/DateTime.php b/src/Form/Element/DateTime.php index 7c7ebff88..86a5c270a 100644 --- a/src/Form/Element/DateTime.php +++ b/src/Form/Element/DateTime.php @@ -79,7 +79,7 @@ public function setTimezone($timezone) public function getValueFromModel() { $value = parent::getValueFromModel(); - if (!empty($value)) { + if (! empty($value)) { return $this->parseValue($value); } } @@ -111,7 +111,7 @@ public function setSeconds($seconds) */ public function setModelAttribute($value) { - $value = !empty($value) + $value = ! empty($value) ? Carbon::createFromFormat($this->getPickerFormat(), $value, $this->getTimezone()) ->timezone(config('app.timezone'))->format($this->getFormat()) : null; diff --git a/src/Form/Element/DependentSelect.php b/src/Form/Element/DependentSelect.php index 34eea3b3f..f4e2fbc10 100644 --- a/src/Form/Element/DependentSelect.php +++ b/src/Form/Element/DependentSelect.php @@ -14,7 +14,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.dependent-select'; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/dependent-select/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@dependentSelect', diff --git a/src/Form/Element/File.php b/src/Form/Element/File.php index e7b4df056..2ec8b766d 100644 --- a/src/Form/Element/File.php +++ b/src/Form/Element/File.php @@ -27,7 +27,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\UploadController@fromField', @@ -127,7 +127,7 @@ public function getUploadValidationRules() */ public function getUploadPath(UploadedFile $file) { - if (!is_callable($this->uploadPath)) { + if (! is_callable($this->uploadPath)) { return $this->defaultUploadPath($file); } @@ -153,7 +153,7 @@ public function setUploadPath(Closure $uploadPath) */ public function getUploadFileName(UploadedFile $file) { - if (!is_callable($this->uploadFileName)) { + if (! is_callable($this->uploadFileName)) { return $this->defaultUploadFilename($file); } diff --git a/src/Form/Element/Image.php b/src/Form/Element/Image.php index 64fdc0092..d5cefe3cf 100644 --- a/src/Form/Element/Image.php +++ b/src/Form/Element/Image.php @@ -37,13 +37,13 @@ class Image extends File */ public function customValidation(Validator $validator) { - $validator->after(function(Validator $validator) { + $validator->after(function (Validator $validator) { /** @var \Illuminate\Http\UploadedFile $file */ $file = array_get($validator->attributes(), 'file'); $size = getimagesize($file->getRealPath()); - if (!$size && $file->getMimeType() !== 'image/svg+xml') { + if (! $size && $file->getMimeType() !== 'image/svg+xml') { $validator->errors()->add('file', trans('sleeping_owl::validation.not_image')); } }); diff --git a/src/Form/Element/Images.php b/src/Form/Element/Images.php index 1a15bbf98..f8dd987b8 100644 --- a/src/Form/Element/Images.php +++ b/src/Form/Element/Images.php @@ -15,7 +15,7 @@ class Images extends Image */ public function storeAsJson() { - $this->mutateValue(function($value) { + $this->mutateValue(function ($value) { return json_encode($value); }); @@ -29,7 +29,7 @@ public function storeAsJson() */ public function storeAsComaSeparatedValue() { - $this->mutateValue(function($value) { + $this->mutateValue(function ($value) { return implode(',', $value); }); @@ -65,7 +65,7 @@ public function save(\Illuminate\Http\Request $request) $name = $this->getName(); $value = $request->input($name, ''); - if (!empty($value)) { + if (! empty($value)) { $value = explode(',', $value); } else { $value = []; diff --git a/src/Form/Element/MultiSelect.php b/src/Form/Element/MultiSelect.php index 30facec1e..16a637439 100644 --- a/src/Form/Element/MultiSelect.php +++ b/src/Form/Element/MultiSelect.php @@ -195,7 +195,7 @@ protected function syncBelongsToManyRelation( array $values ) { foreach ($values as $i => $value) { - if (!array_key_exists($value, $this->getOptions()) && $this->isTaggable()) { + if (! array_key_exists($value, $this->getOptions()) && $this->isTaggable()) { $model = clone $this->getModelForOptions(); $model->{$this->getDisplay()} = $value; $model->save(); @@ -225,7 +225,7 @@ protected function deleteOldItemsFromHasManyRelation( $items = $relation->get(); foreach ($items as $item) { - if (!in_array($item->getKey(), $values)) { + if (! in_array($item->getKey(), $values)) { if ($this->isDeleteRelatedItem()) { $item->delete(); } else { @@ -250,7 +250,7 @@ protected function attachItemsToHasManyRelation( $item = $model->find($value); if (is_null($item)) { - if (!$this->isTaggable()) { + if (! $this->isTaggable()) { continue; } diff --git a/src/Form/Element/MultiSelectAjax.php b/src/Form/Element/MultiSelectAjax.php index 90cd8f403..45f671f47 100644 --- a/src/Form/Element/MultiSelectAjax.php +++ b/src/Form/Element/MultiSelectAjax.php @@ -34,7 +34,7 @@ public function __construct($path, $label = null) { parent::__construct($path, $label); - $this->setLoadOptionsQueryPreparer(function($item, Builder $query) { + $this->setLoadOptionsQueryPreparer(function ($item, Builder $query) { $repository = app(RepositoryInterface::class); $repository->setModel($this->getModelForOptions()); $key = $repository->getModel()->getKeyName(); @@ -107,7 +107,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@multiselectSearch', @@ -175,7 +175,7 @@ protected function loadOptions() $options = $repository->getQuery(); $relation = $this->getModelAttributeKey(); - if ($this->isEmptyRelation() && !is_null($foreignKey = $this->getForeignKey())) { + if ($this->isEmptyRelation() && ! is_null($foreignKey = $this->getForeignKey())) { $model = $this->getModel(); if ($model->{$relation}() instanceof HasOneOrMany) { @@ -190,7 +190,7 @@ protected function loadOptions() } // call the pre load options query preparer if has be set - if (!is_null($preparer = $this->getLoadOptionsQueryPreparer())) { + if (! is_null($preparer = $this->getLoadOptionsQueryPreparer())) { $options = $preparer($this, $options); } @@ -208,7 +208,7 @@ protected function loadOptions() // iterate for all options and redefine it as // list of KEY and TEXT pair - $options = array_map(function($opt) use ($key, $makeDisplay) { + $options = array_map(function ($opt) use ($key, $makeDisplay) { // get the KEY and make the display text return [data_get($opt, $key), $makeDisplay($opt)]; }, $options); @@ -235,7 +235,7 @@ public function afterSave(Request $request) { $attribute = $this->getModelAttributeKey(); - if (!method_exists($this->getModel(), $attribute)) { + if (! method_exists($this->getModel(), $attribute)) { return; } diff --git a/src/Form/Element/NamedFormElement.php b/src/Form/Element/NamedFormElement.php index fef022d3b..746f76ca4 100644 --- a/src/Form/Element/NamedFormElement.php +++ b/src/Form/Element/NamedFormElement.php @@ -85,7 +85,7 @@ private function composeName(array $parts) { $name = array_shift($parts); - while (!empty($parts)) { + while (! empty($parts)) { $part = array_shift($parts); $name .= "[$part]"; } @@ -238,7 +238,7 @@ public function unique($message = null) { $this->addValidationRule('_unique'); - if (!is_null($message)) { + if (! is_null($message)) { $this->addValidationMessage('unique', $message); } @@ -346,7 +346,7 @@ public function resolvePath() */ public function getValueFromRequest(\Illuminate\Http\Request $request) { - if ($request->hasSession() && !is_null($value = $request->old($this->getPath()))) { + if ($request->hasSession() && ! is_null($value = $request->old($this->getPath()))) { return $value; } @@ -358,7 +358,7 @@ public function getValueFromRequest(\Illuminate\Http\Request $request) */ public function getValueFromModel() { - if (!is_null($value = $this->getValueFromRequest(request()))) { + if (! is_null($value = $this->getValueFromRequest(request()))) { return $value; } @@ -366,7 +366,7 @@ public function getValueFromModel() $path = $this->getPath(); $value = $this->getDefaultValue(); - if (is_null($model) || !$model->exists) { + if (is_null($model) || ! $model->exists) { return $value; } @@ -396,7 +396,7 @@ public function getValueFromModel() if ($count === 1) { $attribute = $model->getAttribute($this->getModelAttributeKey()); - if (!empty($attribute) || $attribute === 0 || is_null($value)) { + if (! empty($attribute) || $attribute === 0 || is_null($value)) { return $attribute; } } @@ -410,7 +410,7 @@ public function getValueFromModel() if ($count === 2) { $attribute = $model->getAttribute($relation); - if (!empty($attribute) || is_null($value)) { + if (! empty($attribute) || is_null($value)) { return $attribute; } } diff --git a/src/Form/Element/Password.php b/src/Form/Element/Password.php index 22b730fe8..f25f51f66 100644 --- a/src/Form/Element/Password.php +++ b/src/Form/Element/Password.php @@ -33,7 +33,7 @@ public function save(\Illuminate\Http\Request $request) { $value = $this->getValueFromModel(); - if (!$this->isAllowedEmptyValue() && $this->getModel()->exists && empty($value)) { + if (! $this->isAllowedEmptyValue() && $this->getModel()->exists && empty($value)) { return; } @@ -47,7 +47,7 @@ public function getValidationRules() { $data = parent::getValidationRules(); - if (!$this->isAllowedEmptyValue() && $this->getModel()->exists) { + if (! $this->isAllowedEmptyValue() && $this->getModel()->exists) { foreach ($data as $field => $rules) { foreach ($rules as $i => $rule) { if ($rule == 'required') { @@ -83,7 +83,7 @@ public function allowEmptyValue() */ public function hashWithBcrypt() { - return $this->mutateValue(function($value) { + return $this->mutateValue(function ($value) { return bcrypt($value); }); } @@ -93,7 +93,7 @@ public function hashWithBcrypt() */ public function hashWithMD5() { - return $this->mutateValue(function($value) { + return $this->mutateValue(function ($value) { return md5($value); }); } @@ -103,7 +103,7 @@ public function hashWithMD5() */ public function hashWithSHA1() { - return $this->mutateValue(function($value) { + return $this->mutateValue(function ($value) { return sha1($value); }); } diff --git a/src/Form/Element/SelectAjax.php b/src/Form/Element/SelectAjax.php index 352928754..bcb011468 100644 --- a/src/Form/Element/SelectAjax.php +++ b/src/Form/Element/SelectAjax.php @@ -23,7 +23,7 @@ public function __construct($path, $label = null) { parent::__construct($path, $label); - $this->setLoadOptionsQueryPreparer(function($item, Builder $query) { + $this->setLoadOptionsQueryPreparer(function ($item, Builder $query) { $repository = app(RepositoryInterface::class); $repository->setModel($this->getModelForOptions()); $key = $repository->getModel()->getKeyName(); @@ -39,7 +39,7 @@ public static function registerRoutes(Router $router) { $routeName = 'admin.form.element.'.static::$route; - if (!$router->has($routeName)) { + if (! $router->has($routeName)) { $router->post('{adminModel}/'.static::$route.'/{field}/{id?}', [ 'as' => $routeName, 'uses' => 'SleepingOwl\Admin\Http\Controllers\FormElementController@selectSearch', diff --git a/src/Form/Element/Upload.php b/src/Form/Element/Upload.php index 68f104dc8..19a7ab7e2 100644 --- a/src/Form/Element/Upload.php +++ b/src/Form/Element/Upload.php @@ -42,7 +42,7 @@ public function save(\Illuminate\Http\Request $request) if ($request->input($this->getPath().'_remove')) { $this->setModelAttribute(null); - } elseif (!is_null($value)) { + } elseif (! is_null($value)) { $this->setModelAttribute($value); } } diff --git a/src/Form/Element/View.php b/src/Form/Element/View.php index 6d3bc337e..ea3cd0b6f 100644 --- a/src/Form/Element/View.php +++ b/src/Form/Element/View.php @@ -46,7 +46,7 @@ public function setView($view) { $this->view = $view; - $this->setDisplay(function($model) { + $this->setDisplay(function ($model) { $this->data['model'] = $model; return view($this->getView(), $this->data); diff --git a/src/Form/Element/Wysiwyg.php b/src/Form/Element/Wysiwyg.php index f59dec527..f045a66a8 100644 --- a/src/Form/Element/Wysiwyg.php +++ b/src/Form/Element/Wysiwyg.php @@ -62,7 +62,7 @@ public function initialize() $config = $editor->getConfig(); $config->set($this->parameters); - if (!$this->hasHtmlAttribute('id')) { + if (! $this->hasHtmlAttribute('id')) { $this->setHtmlAttribute('id', $this->getName()); } @@ -70,11 +70,11 @@ public function initialize() $params = collect($this->parameters); - if (!$params->has('uploadUrl')) { + if (! $params->has('uploadUrl')) { $this->parameters['uploadUrl'] = route('admin.ckeditor.upload'); } - if (!$params->has('filebrowserUploadUrl')) { + if (! $params->has('filebrowserUploadUrl')) { $this->parameters['filebrowserUploadUrl'] = route('admin.ckeditor.upload'); } } @@ -179,7 +179,7 @@ public function toArray() */ public function setModelAttribute($value) { - if (!empty($this->filteredFieldKey)) { + if (! empty($this->filteredFieldKey)) { parent::setModelAttribute($value); $this->setModelAttributeKey($this->filteredFieldKey); diff --git a/src/Form/FormButtons.php b/src/Form/FormButtons.php index 96301b218..b97d5c36c 100644 --- a/src/Form/FormButtons.php +++ b/src/Form/FormButtons.php @@ -457,11 +457,11 @@ public function hideSaveAndCreateButton() */ public function isShowDeleteButton() { - if (is_null($this->getModel()->getKey()) || !$this->showDeleteButton) { + if (is_null($this->getModel()->getKey()) || ! $this->showDeleteButton) { return false; } - $this->showDeleteButton = !$this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); + $this->showDeleteButton = ! $this->isTrashed() && $this->getModelConfiguration()->isDeletable($this->getModel()); return $this->showDeleteButton; } @@ -483,7 +483,7 @@ public function hideDeleteButton() */ public function isShowDestroyButton() { - if (is_null($this->getModel()->getKey()) || !$this->showDestroyButton) { + if (is_null($this->getModel()->getKey()) || ! $this->showDestroyButton) { return false; } @@ -510,7 +510,7 @@ public function hideDestroyButton() */ public function isShowRestoreButton() { - if (is_null($this->getModel()->getKey()) || !$this->showRestoreButton) { + if (is_null($this->getModel()->getKey()) || ! $this->showRestoreButton) { return false; } diff --git a/src/Form/FormDefault.php b/src/Form/FormDefault.php index 0b122b429..6f4ea0053 100644 --- a/src/Form/FormDefault.php +++ b/src/Form/FormDefault.php @@ -100,11 +100,11 @@ public function initialize() parent::initialize(); - if (!$this->hasHtmlAttribute('enctype')) { + if (! $this->hasHtmlAttribute('enctype')) { // Try to find upload element - $this->getElements()->each(function($element) { + $this->getElements()->each(function ($element) { // Try to get nested - will be implemented - if ($element instanceof Upload && !$this->hasHtmlAttribute('enctype')) { + if ($element instanceof Upload && ! $this->hasHtmlAttribute('enctype')) { $this->setHtmlAttribute('enctype', 'multipart/form-data'); } }); @@ -209,7 +209,7 @@ public function getItems() */ public function setItems($items) { - if (!is_array($items)) { + if (! is_array($items)) { $items = func_get_args(); } @@ -236,7 +236,7 @@ public function addItem($item) */ public function setId($id) { - if (is_null($this->id) && !is_null($id) && ($model = $this->getRepository()->find($id))) { + if (is_null($this->id) && ! is_null($id) && ($model = $this->getRepository()->find($id))) { $this->id = $id; parent::setModel($model); @@ -297,7 +297,7 @@ public function validModelConfiguration(ModelConfigurationInterface $modelConfig */ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) { - if (!$this->validModelConfiguration($modelConfiguration)) { + if (! $this->validModelConfiguration($modelConfiguration)) { return false; } @@ -337,7 +337,7 @@ public function saveForm(\Illuminate\Http\Request $request, ModelConfigurationIn protected function saveBelongsToRelations(Model $model) { foreach ($model->getRelations() as $name => $relation) { - if ($model->{$name}() instanceof BelongsTo && !is_null($relation)) { + if ($model->{$name}() instanceof BelongsTo && ! is_null($relation)) { $relation->save(); $model->{$name}()->associate($relation); } @@ -352,7 +352,7 @@ protected function saveBelongsToRelations(Model $model) protected function saveHasOneRelations(Model $model) { foreach ($model->getRelations() as $name => $relation) { - if ($model->{$name}() instanceof HasOneOrMany && !is_null($relation)) { + if ($model->{$name}() instanceof HasOneOrMany && ! is_null($relation)) { if (is_array($relation) || $relation instanceof \Traversable) { $model->{$name}()->saveMany($relation); } else { @@ -370,7 +370,7 @@ protected function saveHasOneRelations(Model $model) */ public function validateForm(\Illuminate\Http\Request $request, ModelConfigurationInterface $modelConfiguration = null) { - if (!$this->validModelConfiguration($modelConfiguration)) { + if (! $this->validModelConfiguration($modelConfiguration)) { return; } diff --git a/src/Form/FormElement.php b/src/Form/FormElement.php index a14bd077f..a8bc700e9 100644 --- a/src/Form/FormElement.php +++ b/src/Form/FormElement.php @@ -137,7 +137,7 @@ public function addValidationRule($rule, $message = null) */ public function setValidationRules($validationRules) { - if (!is_array($validationRules)) { + if (! is_array($validationRules)) { $validationRules = func_get_args(); } diff --git a/src/Form/FormElementsCollection.php b/src/Form/FormElementsCollection.php index f9964be6d..a40bafb77 100644 --- a/src/Form/FormElementsCollection.php +++ b/src/Form/FormElementsCollection.php @@ -12,9 +12,9 @@ class FormElementsCollection extends Collection */ public function onlyActive() { - return $this->filter(function($element) { + return $this->filter(function ($element) { if ($element instanceof FormElementInterface) { - return !$element->isReadonly(); + return ! $element->isReadonly(); } return true; @@ -26,7 +26,7 @@ public function onlyActive() */ public function onlyVisible() { - return $this->filter(function($element) { + return $this->filter(function ($element) { if ($element instanceof FormElementInterface) { return $element->isVisible(); } diff --git a/src/Form/FormPanel.php b/src/Form/FormPanel.php index 4afb4a737..ad5e431f3 100644 --- a/src/Form/FormPanel.php +++ b/src/Form/FormPanel.php @@ -40,7 +40,7 @@ public function initialize() */ public function setItems($items) { - if (!is_array($items)) { + if (! is_array($items)) { $items = func_get_args(); } @@ -72,7 +72,7 @@ public function addItem($item) */ public function addHeader($items) { - if (!is_array($items)) { + if (! is_array($items)) { $items = func_get_args(); } @@ -88,7 +88,7 @@ public function addHeader($items) */ public function addBody($items) { - if (!is_array($items)) { + if (! is_array($items)) { $items = func_get_args(); } @@ -109,7 +109,7 @@ public function addBody($items) */ public function addFooter($items) { - if (!is_array($items)) { + if (! is_array($items)) { $items = func_get_args(); } diff --git a/src/Http/Controllers/AdminController.php b/src/Http/Controllers/AdminController.php index f424aa38d..980adfc2f 100644 --- a/src/Http/Controllers/AdminController.php +++ b/src/Http/Controllers/AdminController.php @@ -60,8 +60,8 @@ public function __construct(Request $request, AdminInterface $admin, Application $admin->navigation()->setCurrentUrl($request->getUri()); - if (!$this->breadcrumbs->exists('home')) { - $this->breadcrumbs->register('home', function(Generator $breadcrumbs) { + if (! $this->breadcrumbs->exists('home')) { + $this->breadcrumbs->register('home', function (Generator $breadcrumbs) { $breadcrumbs->push(trans('sleeping_owl::lang.dashboard'), route('admin.dashboard')); }); } @@ -118,7 +118,7 @@ public function getDashboard() */ public function getDisplay(ModelConfigurationInterface $model) { - if (!$model->isDisplayable()) { + if (! $model->isDisplayable()) { abort(404); } @@ -138,7 +138,7 @@ public function getDisplay(ModelConfigurationInterface $model) */ public function getCreate(ModelConfigurationInterface $model) { - if (!$model->isCreatable()) { + if (! $model->isCreatable()) { abort(404); } @@ -158,7 +158,7 @@ public function getCreate(ModelConfigurationInterface $model) */ public function postStore(ModelConfigurationInterface $model, Request $request) { - if (!$model->isCreatable()) { + if (! $model->isCreatable()) { abort(404); } @@ -196,7 +196,7 @@ public function postStore(ModelConfigurationInterface $model, Request $request) $redirectPolicy = $model->getRedirect(); /* Make redirect when use in model config && Fix editable redirect */ - if ($redirectPolicy->get('create') == 'display' || !$model->isEditable($newModel)) { + if ($redirectPolicy->get('create') == 'display' || ! $model->isEditable($newModel)) { $redirectUrl = $model->getDisplayUrl(); } @@ -235,7 +235,7 @@ public function getEdit(ModelConfigurationInterface $model, $id) { $item = $model->getRepository()->find($id); - if (is_null($item) || !$model->isEditable($item)) { + if (is_null($item) || ! $model->isEditable($item)) { abort(404); } @@ -263,7 +263,7 @@ public function postUpdate(ModelConfigurationInterface $model, Request $request, $editForm = $model->fireEdit($id); $item = $editForm->getModel(); - if (is_null($item) || !$model->isEditable($item)) { + if (is_null($item) || ! $model->isEditable($item)) { abort(404); } @@ -342,7 +342,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) /* @var ColumnEditableInterface|null $column */ if (is_callable([$display, 'getColumns'])) { - $column = $display->getColumns()->all()->filter(function($column) use ($field) { + $column = $display->getColumns()->all()->filter(function ($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } else { @@ -351,7 +351,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) $content = $tab->getContent(); if ($content instanceof DisplayTable) { - $column = $content->getColumns()->all()->filter(function($column) use ($field) { + $column = $content->getColumns()->all()->filter(function ($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -360,7 +360,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) //Return data-table if inside FormElements if ($element instanceof DisplayTable) { - $column = $element->getColumns()->all()->filter(function($column) use ($field) { + $column = $element->getColumns()->all()->filter(function ($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -369,7 +369,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) if ($element instanceof Column) { foreach ($element->getElements() as $columnElement) { if ($columnElement instanceof DisplayTable) { - $column = $columnElement->getColumns()->all()->filter(function($column) use ($field) { + $column = $columnElement->getColumns()->all()->filter(function ($column) use ($field) { return ($column instanceof ColumnEditableInterface) && $field == $column->getName(); })->first(); } @@ -388,7 +388,7 @@ public function inlineEdit(ModelConfigurationInterface $model, Request $request) $repository = $model->getRepository(); $item = $repository->find($id); - if (is_null($item) || !$model->isEditable($item)) { + if (is_null($item) || ! $model->isEditable($item)) { abort(404); } @@ -413,7 +413,7 @@ public function deleteDelete(ModelConfigurationInterface $model, Request $reques { $item = $model->getRepository()->find($id); - if (is_null($item) || !$model->isDeletable($item)) { + if (is_null($item) || ! $model->isDeletable($item)) { abort(404); } @@ -442,13 +442,13 @@ public function deleteDelete(ModelConfigurationInterface $model, Request $reques */ public function deleteDestroy(ModelConfigurationInterface $model, Request $request, $id) { - if (!$model->isRestorableModel()) { + if (! $model->isRestorableModel()) { abort(404); } $item = $model->getRepository()->findOnlyTrashed($id); - if (is_null($item) || !$model->isRestorable($item)) { + if (is_null($item) || ! $model->isRestorable($item)) { abort(404); } @@ -477,13 +477,13 @@ public function deleteDestroy(ModelConfigurationInterface $model, Request $reque */ public function postRestore(ModelConfigurationInterface $model, Request $request, $id) { - if (!$model->isRestorableModel()) { + if (! $model->isRestorableModel()) { abort(404); } $item = $model->getRepository()->findOnlyTrashed($id); - if (is_null($item) || !$model->isRestorable($item)) { + if (is_null($item) || ! $model->isRestorable($item)) { abort(404); } @@ -568,7 +568,7 @@ public function getWildcard() */ protected function registerBreadcrumb($title, $parent) { - $this->breadcrumbs->register('render', function(Generator $breadcrumbs) use ($title, $parent) { + $this->breadcrumbs->register('render', function (Generator $breadcrumbs) use ($title, $parent) { $breadcrumbs->parent($parent); $breadcrumbs->push($title); }); @@ -584,8 +584,8 @@ protected function registerBreadcrumbs(ModelConfigurationInterface $model) $this->breadCrumbsData = $this->breadCrumbsData + (array) $model->getBreadCrumbs(); foreach ($this->breadCrumbsData as $breadcrumb) { - if (!$this->breadcrumbs->exists($breadcrumb['id'])) { - $this->breadcrumbs->register($breadcrumb['id'], function(Generator $breadcrumbs) use ($breadcrumb) { + if (! $this->breadcrumbs->exists($breadcrumb['id'])) { + $this->breadcrumbs->register($breadcrumb['id'], function (Generator $breadcrumbs) use ($breadcrumb) { $breadcrumbs->parent($breadcrumb['parent']); $breadcrumbs->push($breadcrumb['title'], $breadcrumb['url']); }); diff --git a/src/Http/Controllers/DisplayController.php b/src/Http/Controllers/DisplayController.php index 9574438f1..4f44dbeb6 100644 --- a/src/Http/Controllers/DisplayController.php +++ b/src/Http/Controllers/DisplayController.php @@ -86,7 +86,7 @@ public function treeReorder(ModelConfigurationInterface $model, Request $request $display = $model->fireDisplay(); if ($display instanceof DisplayTabbed) { - $display->getTabs()->each(function(DisplayTab $tab) use ($request) { + $display->getTabs()->each(function (DisplayTab $tab) use ($request) { $content = $tab->getContent(); if ($content instanceof DisplayTree) { $content->getRepository()->reorder( diff --git a/src/Http/Controllers/FormElementController.php b/src/Http/Controllers/FormElementController.php index 5f0b1a67f..05addc36a 100644 --- a/src/Http/Controllers/FormElementController.php +++ b/src/Http/Controllers/FormElementController.php @@ -18,9 +18,9 @@ class FormElementController extends Controller */ public function getModelLogic(ModelConfigurationInterface $model, $id = null) { - if (!is_null($id)) { + if (! is_null($id)) { $item = $model->getRepository()->find($id); - if (is_null($item) || !$model->isEditable($item)) { + if (is_null($item) || ! $model->isEditable($item)) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -29,7 +29,7 @@ public function getModelLogic(ModelConfigurationInterface $model, $id = null) return $model->fireEdit($id); } - if (!$model->isCreatable()) { + if (! $model->isCreatable()) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -74,7 +74,7 @@ public function dependentSelect(Request $request, ModelConfigurationInterface $m } return new JsonResponse([ - 'output' => collect($options)->map(function($value, $key) { + 'output' => collect($options)->map(function ($value, $key) { return ['id' => $key, 'name' => $value]; }), 'selected' => $element->getValueFromModel(), @@ -126,7 +126,7 @@ public function selectSearch(Request $request, ModelConfigurationInterface $mode return new JsonResponse( $model::where($request->search, 'like', "%{$request->q}%") ->get() - ->map(function(Model $item) use ($field) { + ->map(function (Model $item) use ($field) { return [ 'tag_name' => $item->{$field}, 'id' => $item->id, diff --git a/src/Http/Controllers/UploadController.php b/src/Http/Controllers/UploadController.php index 7d31470f7..afcce4cd7 100644 --- a/src/Http/Controllers/UploadController.php +++ b/src/Http/Controllers/UploadController.php @@ -23,9 +23,9 @@ class UploadController extends Controller */ public function fromField(Request $request, ModelConfigurationInterface $model, $field, $id = null) { - if (!is_null($id)) { + if (! is_null($id)) { $item = $model->getRepository()->find($id); - if (is_null($item) || !$model->isEditable($item)) { + if (is_null($item) || ! $model->isEditable($item)) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); @@ -33,7 +33,7 @@ public function fromField(Request $request, ModelConfigurationInterface $model, $form = $model->fireEdit($id); } else { - if (!$model->isCreatable()) { + if (! $model->isCreatable()) { return new JsonResponse([ 'message' => trans('lang.message.access_denied'), ], 403); diff --git a/src/Http/routes.php b/src/Http/routes.php index bdb120893..33414a1dc 100644 --- a/src/Http/routes.php +++ b/src/Http/routes.php @@ -2,8 +2,8 @@ use Illuminate\Routing\Router; -$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function(Router $router) { - if (!$router->has('admin.dashboard')) { +$router->group(['as' => 'admin.', 'namespace' => 'SleepingOwl\Admin\Http\Controllers'], function (Router $router) { + if (! $router->has('admin.dashboard')) { $router->get('', ['as' => 'dashboard', 'uses' => 'AdminController@getDashboard']); } diff --git a/src/Model/ModelCollection.php b/src/Model/ModelCollection.php index 977b61bf3..80e81ec79 100644 --- a/src/Model/ModelCollection.php +++ b/src/Model/ModelCollection.php @@ -12,7 +12,7 @@ class ModelCollection extends Collection */ public function aliases() { - return $this->map(function(ModelConfigurationInterface $model) { + return $this->map(function (ModelConfigurationInterface $model) { return $model->getAlias(); }); } @@ -22,7 +22,7 @@ public function aliases() */ public function keyByAlias() { - return $this->keyBy(function(ModelConfigurationInterface $model) { + return $this->keyBy(function (ModelConfigurationInterface $model) { return $model->getAlias(); }); } diff --git a/src/Model/ModelConfiguration.php b/src/Model/ModelConfiguration.php index ba77e5b8d..f00b50630 100644 --- a/src/Model/ModelConfiguration.php +++ b/src/Model/ModelConfiguration.php @@ -229,7 +229,7 @@ public function disableDisplay() */ public function can($action, Model $model) { - if (!$this->checkAccess) { + if (! $this->checkAccess) { return true; } @@ -241,7 +241,7 @@ public function can($action, Model $model) */ public function isCreatable() { - if (!is_callable($this->getCreate())) { + if (! is_callable($this->getCreate())) { return false; } @@ -265,7 +265,7 @@ public function disableCreating() */ public function isEditable(Model $model) { - if (!is_callable($this->getEdit())) { + if (! is_callable($this->getEdit())) { return false; } @@ -388,7 +388,7 @@ public function onDisplay(Closure $callback) */ public function fireDisplay(array $payload = []) { - if (!is_callable($this->getDisplay())) { + if (! is_callable($this->getDisplay())) { return; } @@ -434,7 +434,7 @@ public function onCreate(Closure $callback = null) */ public function fireCreate() { - if (!is_callable($this->getCreate())) { + if (! is_callable($this->getCreate())) { return; } @@ -481,7 +481,7 @@ public function onEdit(Closure $callback = null) */ public function fireEdit($id) { - if (!is_callable($this->getEdit())) { + if (! is_callable($this->getEdit())) { return; } diff --git a/src/Model/ModelConfigurationManager.php b/src/Model/ModelConfigurationManager.php index 0a725820e..6505f2ad8 100644 --- a/src/Model/ModelConfigurationManager.php +++ b/src/Model/ModelConfigurationManager.php @@ -115,7 +115,7 @@ public function __construct(\Illuminate\Contracts\Foundation\Application $app, $ $this->repository = $app->make(RepositoryInterface::class); $this->repository->setClass($class); - if (!$this->alias) { + if (! $this->alias) { $this->setDefaultAlias(); } } @@ -304,7 +304,7 @@ public function disableAccessCheck() */ public function can($action, Model $model) { - if (!$this->checkAccess) { + if (! $this->checkAccess) { return true; } @@ -338,7 +338,7 @@ public function hasCustomControllerClass() { $controller = $this->getControllerClass(); - return !is_null($controller) && class_exists($controller); + return ! is_null($controller) && class_exists($controller); } /** @@ -517,7 +517,7 @@ protected function makePage($priority = 100, $badge = null) $page->setPriority($priority); if ($badge) { - if (!($badge instanceof BadgeInterface)) { + if (! ($badge instanceof BadgeInterface)) { $badge = new Badge($badge); } @@ -558,7 +558,7 @@ public function getRedirect() */ public function fireEvent($event, $halt = true, Model $model = null, ...$payload) { - if (!isset(self::$dispatcher)) { + if (! isset(self::$dispatcher)) { return true; } diff --git a/src/Model/SectionModelConfiguration.php b/src/Model/SectionModelConfiguration.php index e6b654cda..3d799a7a7 100644 --- a/src/Model/SectionModelConfiguration.php +++ b/src/Model/SectionModelConfiguration.php @@ -64,7 +64,7 @@ public function isDeletable(Model $model) */ public function fireDisplay(array $payload = []) { - if (!method_exists($this, 'onDisplay')) { + if (! method_exists($this, 'onDisplay')) { return; } @@ -87,7 +87,7 @@ public function fireDisplay(array $payload = []) */ public function fireCreate() { - if (!method_exists($this, 'onCreate')) { + if (! method_exists($this, 'onCreate')) { return; } @@ -114,7 +114,7 @@ public function fireCreate() */ public function fireEdit($id) { - if (!method_exists($this, 'onEdit')) { + if (! method_exists($this, 'onEdit')) { return; } diff --git a/src/Navigation.php b/src/Navigation.php index f63f93b91..e46ddcac5 100644 --- a/src/Navigation.php +++ b/src/Navigation.php @@ -30,7 +30,7 @@ public function getCurrentPage() */ public function setAliasesId(Collection $pages) { - $pages->each(function(PageInterface $page) { + $pages->each(function (PageInterface $page) { $page->setAliasId(); if ($page->getPages()->count()) { @@ -54,7 +54,7 @@ protected function findActive($url, array &$foundPages) */ protected function findPageByAliasId(Collection $pages, $url) { - $pages->each(function(PageInterface $page) use ($url) { + $pages->each(function (PageInterface $page) use ($url) { $urlPath = parse_url($url, PHP_URL_PATH); if (Route::current()) { @@ -86,7 +86,7 @@ protected function findPageByAliasId(Collection $pages, $url) */ protected function findActivePage() { - if (!is_null($this->currentPage)) { + if (! is_null($this->currentPage)) { return true; } @@ -96,7 +96,7 @@ protected function findActivePage() $this->findActive($url, $foundPages); - if (!is_null($this->currentPage)) { + if (! is_null($this->currentPage)) { $this->currentPage->setActive(); } diff --git a/src/Navigation/Badge.php b/src/Navigation/Badge.php index 26195904c..ac195cf63 100644 --- a/src/Navigation/Badge.php +++ b/src/Navigation/Badge.php @@ -13,7 +13,7 @@ public function toArray() { $value = $this->getValue(); - if (!$this->hasClassProperty('label-', 'bg-')) { + if (! $this->hasClassProperty('label-', 'bg-')) { $this->setHtmlAttribute('class', 'label-primary'); } diff --git a/src/Navigation/Page.php b/src/Navigation/Page.php index fb3b95c1e..6f4b87235 100644 --- a/src/Navigation/Page.php +++ b/src/Navigation/Page.php @@ -57,7 +57,7 @@ public function getAliasId() */ public function getModelConfiguration() { - if (!$this->hasModel()) { + if (! $this->hasModel()) { return; } @@ -69,7 +69,7 @@ public function getModelConfiguration() */ public function hasModel() { - return !is_null($this->model) && class_exists($this->model); + return ! is_null($this->model) && class_exists($this->model); } /** @@ -113,9 +113,9 @@ public function getUrl() */ public function getAccessLogic() { - if (!is_callable($this->accessLogic)) { + if (! is_callable($this->accessLogic)) { if ($this->hasModel()) { - return function() { + return function () { return $this->getModelConfiguration()->isDisplayable(); }; } @@ -131,13 +131,13 @@ public function getAccessLogic() */ public function render($view = null) { - if ($this->hasChild() && !$this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) { + if ($this->hasChild() && ! $this->hasClassProperty($class = config('navigation.class.has_child', 'treeview'))) { $this->setHtmlAttribute('class', $class); } $data = $this->toArray(); - if (!is_null($view)) { + if (! is_null($view)) { return view($view, $data)->render(); } diff --git a/src/Providers/AdminServiceProvider.php b/src/Providers/AdminServiceProvider.php index 93e2837ad..d87434de6 100644 --- a/src/Providers/AdminServiceProvider.php +++ b/src/Providers/AdminServiceProvider.php @@ -42,17 +42,17 @@ public function register() $this->initializeNavigation(); $this->registerAliases(); - $this->app->singleton('sleeping_owl.widgets', function() { + $this->app->singleton('sleeping_owl.widgets', function () { return new WidgetsRegistry($this->app); }); - $this->app->booted(function() { + $this->app->booted(function () { $this->app['sleeping_owl.widgets']->placeWidgets( $this->app[ViewFactory::class] ); }); - $this->app->booted(function() { + $this->app->booted(function () { $this->registerCustomRoutes(); $this->registerDefaultRoutes(); $this->registerSupportRoutes(); @@ -66,11 +66,11 @@ public function register() protected function registerTemplate() { - $this->app->singleton('assets.packages', function($app) { + $this->app->singleton('assets.packages', function ($app) { return new \KodiCMS\Assets\PackageManager(); }); - $this->app->singleton('sleeping_owl.meta', function($app) { + $this->app->singleton('sleeping_owl.meta', function ($app) { return new Meta( new Assets( $app['assets.packages'] @@ -78,8 +78,8 @@ protected function registerTemplate() ); }); - $this->app->singleton('sleeping_owl.template', function(Application $app) { - if (!class_exists($class = $this->getConfig('template'))) { + $this->app->singleton('sleeping_owl.template', function (Application $app) { + if (! class_exists($class = $this->getConfig('template'))) { throw new TemplateException("Template class [{$class}] not found"); } @@ -108,7 +108,7 @@ protected function getConfig($key) */ protected function getBootstrapPath($path = null) { - if (!is_null($path)) { + if (! is_null($path)) { $path = DIRECTORY_SEPARATOR.$path; } @@ -136,7 +136,7 @@ protected function registerMessages() $this->app[WidgetsRegistryInterface::class]->registerWidget($messageType); } - $this->app->singleton('sleeping_owl.message', function() use ($messageTypes) { + $this->app->singleton('sleeping_owl.message', function () use ($messageTypes) { return new MessageStack($messageTypes); }); } @@ -168,14 +168,14 @@ protected function initializeNavigation() \SleepingOwl\Admin\Navigation\Badge::class ); - $this->app->singleton('sleeping_owl.navigation', function() { + $this->app->singleton('sleeping_owl.navigation', function () { return new Navigation(); }); } protected function registerWysiwyg() { - $this->app->singleton('sleeping_owl.wysiwyg', function() { + $this->app->singleton('sleeping_owl.wysiwyg', function () { return new Manager($this->app); }); } @@ -187,7 +187,7 @@ protected function registerBootstrap() { $directory = $this->getBootstrapPath(); - if (!is_dir($directory)) { + if (! is_dir($directory)) { return; } @@ -197,7 +197,7 @@ protected function registerBootstrap() ->notName('routes.php') ->notName('navigation.php') ->in($directory) - ->sort(function(SplFileInfo $a) { + ->sort(function (SplFileInfo $a) { return $a->getFilename() != 'bootstrap.php'; }); @@ -220,7 +220,7 @@ protected function registerAliases() protected function registerCustomRoutes() { if (file_exists($file = $this->getBootstrapPath('routes.php'))) { - $this->registerRoutes(function(Router $route) use ($file) { + $this->registerRoutes(function (Router $route) use ($file) { require $file; }); } @@ -231,7 +231,7 @@ protected function registerCustomRoutes() */ protected function registerDefaultRoutes() { - $this->registerRoutes(function(Router $router) { + $this->registerRoutes(function (Router $router) { (new ModelRouter($this->app, $router))->register($this->app['sleeping_owl']->getModels()); if (file_exists($routesFile = __DIR__.'/../Http/routes.php')) { @@ -250,7 +250,7 @@ protected function registerSupportRoutes() $domain = config('sleeping_owl.domain', false); $middlewares = collect($this->getConfig('middleware')); - $middlewares = $middlewares->filter(function($item) { + $middlewares = $middlewares->filter(function ($item) { return $item != 'web'; }); $configGroup = collect([ @@ -262,7 +262,7 @@ protected function registerSupportRoutes() $configGroup->put('domain', $domain); } - $this->app['router']->group($configGroup->toArray(), function(Router $route) { + $this->app['router']->group($configGroup->toArray(), function (Router $route) { $route->get('ckeditor/upload/image', [ 'as' => 'admin.ckeditor.upload', 'uses' => 'SleepingOwl\Admin\Http\Controllers\UploadController@ckEditorStore', @@ -290,7 +290,7 @@ protected function registerRoutes(\Closure $callback) $configGroup->put('domain', $domain); } - $this->app['router']->group($configGroup->toArray(), function(Router $route) use ($callback) { + $this->app['router']->group($configGroup->toArray(), function (Router $route) use ($callback) { call_user_func($callback, $route); }); } diff --git a/src/Providers/BreadcrumbsServiceProvider.php b/src/Providers/BreadcrumbsServiceProvider.php index a7cf9ca6c..84cb6987f 100644 --- a/src/Providers/BreadcrumbsServiceProvider.php +++ b/src/Providers/BreadcrumbsServiceProvider.php @@ -21,7 +21,7 @@ class BreadcrumbsServiceProvider extends ServiceProvider */ public function register() { - $this->app->singleton('sleeping_owl.breadcrumbs', function() { + $this->app->singleton('sleeping_owl.breadcrumbs', function () { return $this->app->make(Breadcrumbs::class); }); } diff --git a/src/Providers/SleepingOwlServiceProvider.php b/src/Providers/SleepingOwlServiceProvider.php index 57e0a3973..1f7488d8f 100644 --- a/src/Providers/SleepingOwlServiceProvider.php +++ b/src/Providers/SleepingOwlServiceProvider.php @@ -51,7 +51,7 @@ protected function registerCore() private function createLocalViewFactory() { $resolver = new EngineResolver(); - $resolver->register('php', function() { + $resolver->register('php', function () { return new PhpEngine(); }); $finder = new FileViewFinder($this->app['files'], [__DIR__.'/../../resources/views']); @@ -64,8 +64,8 @@ private function createLocalViewFactory() protected function registerCommands() { if ($this->app->runningInConsole()) { - if (!class_exists('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider') && - !$this->app->resolved('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { + if (! class_exists('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider') && + ! $this->app->resolved('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) { $this->app->register('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'); } @@ -81,7 +81,7 @@ protected function registerCommands() $localViewFactory = $this->createLocalViewFactory(); $this->app->singleton( 'command.sleepingowl.ide.generate', - function($app) use ($localViewFactory) { + function ($app) use ($localViewFactory) { return new \SleepingOwl\Admin\Console\Commands\GeneratorCommand($app['config'], $app['files'], $localViewFactory); } ); diff --git a/src/Repositories/BaseRepository.php b/src/Repositories/BaseRepository.php index c5775717b..cb498606d 100644 --- a/src/Repositories/BaseRepository.php +++ b/src/Repositories/BaseRepository.php @@ -43,7 +43,7 @@ public function getClass() */ public function setClass($class) { - if (!class_exists($class)) { + if (! class_exists($class)) { throw new RepositoryException("Class {$class} not found."); } @@ -90,7 +90,7 @@ public function getWith() */ public function with($with) { - if (!is_array($with)) { + if (! is_array($with)) { $with = func_get_args(); } diff --git a/src/Repositories/TreeRepository.php b/src/Repositories/TreeRepository.php index 08aa712fb..7be3a1d19 100644 --- a/src/Repositories/TreeRepository.php +++ b/src/Repositories/TreeRepository.php @@ -40,7 +40,7 @@ class TreeRepository extends BaseRepository implements TreeRepositoryInterface */ public function __construct($treeType = null) { - if (!is_null($treeType)) { + if (! is_null($treeType)) { $this->setTreeType($treeType); } } @@ -54,7 +54,7 @@ public function setTreeType($treeType) { $this->treeType = new $treeType($this); - if (!($this->treeType instanceof TreeTypeInterface)) { + if (! ($this->treeType instanceof TreeTypeInterface)) { throw new DisplayTreeException('Tree type class must be instanced of [SleepingOwl\Admin\Contracts\Display\Tree\TreeTypeInterface]'); } } diff --git a/src/Routing/ModelRouter.php b/src/Routing/ModelRouter.php index b28bbc1a4..8c56b0f9e 100644 --- a/src/Routing/ModelRouter.php +++ b/src/Routing/ModelRouter.php @@ -59,7 +59,7 @@ protected function registerModelPatterns(Collection $aliases) */ protected function registerModelBindings(Collection $aliases) { - $this->router->bind('adminModel', function($model, Route $route) use ($aliases) { + $this->router->bind('adminModel', function ($model, Route $route) use ($aliases) { if (is_null($model = $aliases->get($model))) { throw new ModelNotFoundException(); } @@ -85,7 +85,7 @@ protected function registerModelBindings(Collection $aliases) */ protected function runCustomController(Route $route, $controller, $action) { - $route->uses(function() use ($route, $controller, $action) { + $route->uses(function () use ($route, $controller, $action) { return (new ControllerDispatcher($this->app))->dispatch( $route, $this->app->make($controller), $action ); diff --git a/src/Templates/Assets.php b/src/Templates/Assets.php index 6cfe2b5d6..8df1c1f55 100644 --- a/src/Templates/Assets.php +++ b/src/Templates/Assets.php @@ -37,11 +37,11 @@ public function addJs($handle = false, $src = null, $dependency = null, $footer */ protected function sort($assets) { - $mainAssets = collect($assets)->filter(function(AssetElement $item) { - return !array_filter($item->getDependency()); + $mainAssets = collect($assets)->filter(function (AssetElement $item) { + return ! array_filter($item->getDependency()); }); - $depAssets = collect($assets)->filter(function(AssetElement $item) { + $depAssets = collect($assets)->filter(function (AssetElement $item) { return array_filter($item->getDependency()); }); @@ -69,7 +69,7 @@ protected function insertOn(AssetElement $asset, Collection &$mainAssets, Collec $hasNotDep = null; foreach ($dependency as $dep) { - if (!$mainAssets->has($dep)) { + if (! $mainAssets->has($dep)) { $hasNotDep = $dep; break; } diff --git a/src/Templates/Breadcrumbs.php b/src/Templates/Breadcrumbs.php index 26bf17610..ac39a4200 100644 --- a/src/Templates/Breadcrumbs.php +++ b/src/Templates/Breadcrumbs.php @@ -35,7 +35,7 @@ public function renderIfExists($name = null) $name = $params[0]; } - if (!$this->exists($name)) { + if (! $this->exists($name)) { return ''; } @@ -61,7 +61,7 @@ public function renderArray($name, $params = []) */ public function renderIfExistsArray($name, $params = []) { - if (!$this->exists($name)) { + if (! $this->exists($name)) { return ''; } diff --git a/src/Traits/FormElements.php b/src/Traits/FormElements.php index 270fcc348..612a41240 100644 --- a/src/Traits/FormElements.php +++ b/src/Traits/FormElements.php @@ -23,7 +23,7 @@ trait FormElements */ public function initializeElements() { - $this->getElements()->each(function($element) { + $this->getElements()->each(function ($element) { if ($element instanceof Initializable) { $element->initialize(); } @@ -41,7 +41,7 @@ public function getElement($path) foreach ($this->getElements() as $element) { if ($element instanceof ElementsInterface) { - if (!is_null($found = $element->getElement($path))) { + if (! is_null($found = $element->getElement($path))) { return $found; } } @@ -145,7 +145,7 @@ public function afterSave(\Illuminate\Http\Request $request) */ protected function setModelForElements(Model $model) { - $this->getElements()->each(function($element) use ($model) { + $this->getElements()->each(function ($element) use ($model) { $element = $this->getElementContainer($element); if ($element instanceof WithModelInterface) { @@ -163,7 +163,7 @@ protected function setModelForElements(Model $model) */ protected function getValidationRulesFromElements(array $rules = []) { - $this->getElements()->onlyActive()->each(function($element) use (&$rules) { + $this->getElements()->onlyActive()->each(function ($element) use (&$rules) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -181,7 +181,7 @@ protected function getValidationRulesFromElements(array $rules = []) */ protected function getValidationMessagesForElements(array $messages = []) { - $this->getElements()->onlyActive()->each(function($element) use (&$messages) { + $this->getElements()->onlyActive()->each(function ($element) use (&$messages) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -199,7 +199,7 @@ protected function getValidationMessagesForElements(array $messages = []) */ protected function getValidationLabelsForElements(array $labels = []) { - $this->getElements()->onlyActive()->each(function($element) use (&$labels) { + $this->getElements()->onlyActive()->each(function ($element) use (&$labels) { $element = $this->getElementContainer($element); if ($element instanceof Validable) { @@ -217,7 +217,7 @@ protected function getValidationLabelsForElements(array $labels = []) */ protected function saveElements(\Illuminate\Http\Request $request) { - $this->getElements()->onlyActive()->each(function($element) use ($request) { + $this->getElements()->onlyActive()->each(function ($element) use ($request) { $element = $this->getElementContainer($element); if ($element instanceof FormElementInterface) { @@ -233,7 +233,7 @@ protected function saveElements(\Illuminate\Http\Request $request) */ protected function afterSaveElements(\Illuminate\Http\Request $request) { - $this->getElements()->onlyActive()->each(function($element) use ($request) { + $this->getElements()->onlyActive()->each(function ($element) use ($request) { $element = $this->getElementContainer($element); if ($element instanceof FormElementInterface) { diff --git a/src/Traits/OrderableModel.php b/src/Traits/OrderableModel.php index a3f27012a..b5dceea23 100644 --- a/src/Traits/OrderableModel.php +++ b/src/Traits/OrderableModel.php @@ -17,16 +17,16 @@ trait OrderableModel */ protected static function bootOrderableModel() { - static::creating(function(Model $row) { + static::creating(function (Model $row) { $row->updateOrderFieldOnCreate(); }); - static::deleted(function(Model $row) { + static::deleted(function (Model $row) { $row->updateOrderFieldOnDelete(); }); if (in_array("Illuminate\Database\Eloquent\SoftDeletes", trait_uses_recursive(new static()))) { - static::restoring(function(Model $row) { + static::restoring(function (Model $row) { $row->updateOrderFieldOnRestore(); }); } diff --git a/src/Traits/SelectOptionsFromModel.php b/src/Traits/SelectOptionsFromModel.php index 085fc5666..bf8e0c259 100644 --- a/src/Traits/SelectOptionsFromModel.php +++ b/src/Traits/SelectOptionsFromModel.php @@ -64,7 +64,7 @@ public function setModelForOptions($modelForOptions) $modelForOptions = app($modelForOptions); } - if (!($modelForOptions instanceof Model)) { + if (! ($modelForOptions instanceof Model)) { throw new SelectException('Class must be instanced of Illuminate\Database\Eloquent\Model'); } @@ -121,7 +121,7 @@ public function setDisplay($display) */ public function setFetchColumns($columns) { - if (!is_array($columns)) { + if (! is_array($columns)) { $columns = func_get_args(); } @@ -216,7 +216,7 @@ protected function loadOptions() $options = $repository->getQuery(); - if ($this->isEmptyRelation() && !is_null($foreignKey = $this->getForeignKey())) { + if ($this->isEmptyRelation() && ! is_null($foreignKey = $this->getForeignKey())) { $relation = $this->getModelAttributeKey(); $model = $this->getModel(); @@ -232,7 +232,7 @@ protected function loadOptions() } // call the pre load options query preparer if has be set - if (!is_null($preparer = $this->getLoadOptionsQueryPreparer())) { + if (! is_null($preparer = $this->getLoadOptionsQueryPreparer())) { $options = $preparer($this, $options); } @@ -249,7 +249,7 @@ protected function loadOptions() // iterate for all options and redefine it as // list of KEY and TEXT pair - $options = array_map(function($opt) use ($key, $makeDisplay) { + $options = array_map(function ($opt) use ($key, $makeDisplay) { // get the KEY and make the display text return [data_get($opt, $key), $makeDisplay($opt)]; }, $options); diff --git a/src/Traits/SqlQueryOperators.php b/src/Traits/SqlQueryOperators.php index 9ef3ea6df..74276a43d 100644 --- a/src/Traits/SqlQueryOperators.php +++ b/src/Traits/SqlQueryOperators.php @@ -54,7 +54,7 @@ public function getOperator() */ public function setOperator($operator) { - if (!array_key_exists($operator, $this->sqlOperators)) { + if (! array_key_exists($operator, $this->sqlOperators)) { throw new FilterOperatorException("Operator [$operator] not found"); } @@ -119,13 +119,13 @@ protected function prepareValue($value) break; case 'whereBetween': case 'whereNotBetween': - if (!is_array($value)) { + if (! is_array($value)) { $value = explode(',', $value, 2); } break; case 'whereIn': case 'whereNotIn': - if (!is_array($value)) { + if (! is_array($value)) { $value = explode(',', $value); } break; diff --git a/src/Widgets/WidgetsRegistry.php b/src/Widgets/WidgetsRegistry.php index 8211d4e2d..36a734843 100644 --- a/src/Widgets/WidgetsRegistry.php +++ b/src/Widgets/WidgetsRegistry.php @@ -54,22 +54,22 @@ public function placeWidgets(Factory $factory) } $groupedBlocks = $this->widgets - ->map(function($class) { + ->map(function ($class) { return $this->makeWidget($class); }) - ->filter(function(WidgetInterface $block) { + ->filter(function (WidgetInterface $block) { return $block->active(); }) - ->groupBy(function(WidgetInterface $block) { + ->groupBy(function (WidgetInterface $block) { return $block->template(); }); foreach ($groupedBlocks as $template => $widgets) { - $factory->composer($template, function(View $view) use ($widgets) { + $factory->composer($template, function (View $view) use ($widgets) { $factory = $view->getFactory(); /** @var Collection|WidgetInterface[] $widgets */ - $widgets = $widgets->sortBy(function(WidgetInterface $block) { + $widgets = $widgets->sortBy(function (WidgetInterface $block) { return $block->position(); }); diff --git a/src/Wysiwyg/Manager.php b/src/Wysiwyg/Manager.php index 48b729998..50e721f7a 100644 --- a/src/Wysiwyg/Manager.php +++ b/src/Wysiwyg/Manager.php @@ -83,7 +83,7 @@ public function getFilters() */ public function getEditor($editorId) { - return $this->getFilters()->filter(function(WysiwygEditorInterface $editor) use ($editorId) { + return $this->getFilters()->filter(function (WysiwygEditorInterface $editor) use ($editorId) { return $editor->getId() == $editorId; })->first(); } @@ -100,7 +100,7 @@ public function loadDefaultEditor() */ public function loadEditor($editorId) { - if (!is_null($editor = $this->getEditor($editorId))) { + if (! is_null($editor = $this->getEditor($editorId))) { if ($editor->isUsed()) { return true; } @@ -120,7 +120,7 @@ public function loadEditor($editorId) */ public function applyFilter($editorId, $text) { - if (!is_null($editor = $this->getEditor($editorId))) { + if (! is_null($editor = $this->getEditor($editorId))) { return $editor->applyFilter($text); } From 57ed57d7e29cfa96f7d75fe203954dc30404a178 Mon Sep 17 00:00:00 2001 From: Aios Date: Tue, 22 May 2018 01:51:07 +0300 Subject: [PATCH 003/108] First page of scrutinizer issues --- resources/views/default/form/tabbed.blade.php | 5 +++-- src/Display/Column/Checkbox.php | 2 +- src/Display/Column/Control.php | 2 +- src/Display/Column/Editable/Checkbox.php | 8 ++++---- src/Display/Column/Editable/DateTime.php | 6 ++++++ src/Display/Column/Editable/EditableColumn.php | 9 ++++----- src/Display/Column/Filter/DateRange.php | 3 +-- src/Display/Column/Filter/Range.php | 8 ++++---- src/Display/Column/NamedColumn.php | 5 +++++ src/Display/Column/Order.php | 13 +++++++------ src/Display/DisplayTable.php | 3 ++- src/Display/DisplayTree.php | 6 ++++-- src/Display/Extension/Tree.php | 5 +++++ src/Display/TableColumn.php | 2 +- src/Display/Tree/BaumNodeType.php | 8 +++----- src/Display/Tree/KalnoyNestedsetType.php | 6 +++--- 16 files changed, 54 insertions(+), 37 deletions(-) diff --git a/resources/views/default/form/tabbed.blade.php b/resources/views/default/form/tabbed.blade.php index b4d447e5f..c349ff365 100644 --- a/resources/views/default/form/tabbed.blade.php +++ b/resources/views/default/form/tabbed.blade.php @@ -5,12 +5,13 @@