diff --git a/app/admin/actions/AssigneeController.php b/app/admin/actions/AssigneeController.php index 427e21d5ca..66249f987f 100644 --- a/app/admin/actions/AssigneeController.php +++ b/app/admin/actions/AssigneeController.php @@ -124,7 +124,7 @@ protected function assigneeBindFormEvents() return; $assignable = $widget->model; - if (!$assignable->hasAssignToGroup() OR $assignable->hasAssignTo()) + if (!$assignable->hasAssignToGroup() || $assignable->hasAssignTo()) return; // Let the allocator handle assignment when auto assign is enabled diff --git a/app/admin/actions/CalendarController.php b/app/admin/actions/CalendarController.php index 4705f64bfc..93c0fdad32 100644 --- a/app/admin/actions/CalendarController.php +++ b/app/admin/actions/CalendarController.php @@ -128,7 +128,7 @@ protected function makeCalendar($alias) $widget->bindToController(); // Prep the optional toolbar widget - if (isset($modelConfig['toolbar']) AND isset($this->controller->widgets['toolbar'])) { + if (isset($modelConfig['toolbar']) && isset($this->controller->widgets['toolbar'])) { $this->toolbarWidget = $this->controller->widgets['toolbar']; if ($this->toolbarWidget instanceof \Admin\Widgets\Toolbar) $this->toolbarWidget->reInitialize($modelConfig['toolbar']); @@ -139,7 +139,7 @@ protected function makeCalendar($alias) public function renderCalendar($alias = null) { - if (is_null($alias) OR !isset($this->listConfig[$alias])) + if (is_null($alias) || !isset($this->listConfig[$alias])) $alias = $this->primaryAlias; $list = []; diff --git a/app/admin/actions/FormController.php b/app/admin/actions/FormController.php index 096a4bfb9c..fc0c8c5081 100644 --- a/app/admin/actions/FormController.php +++ b/app/admin/actions/FormController.php @@ -199,7 +199,7 @@ public function initForm($model, $context = null) $this->formWidget->bindToController(); // Prep the optional toolbar widget - if (isset($modelConfig['toolbar']) AND isset($this->controller->widgets['toolbar'])) { + if (isset($modelConfig['toolbar']) && isset($this->controller->widgets['toolbar'])) { $this->toolbarWidget = $this->controller->widgets['toolbar']; if ($this->toolbarWidget instanceof Toolbar) { $this->toolbarWidget->reInitialize($modelConfig['toolbar']); @@ -440,11 +440,11 @@ protected function createModel() public function makeRedirect($context = null, $model = null) { $redirectUrl = null; - if (post('new') AND !ends_with($context, '-new')) { + if (post('new') && !ends_with($context, '-new')) { $context .= '-new'; } - if (post('close') AND !ends_with($context, '-close')) { + if (post('close') && !ends_with($context, '-close')) { $context .= '-close'; } @@ -454,7 +454,7 @@ public function makeRedirect($context = null, $model = null) $redirectUrl = $this->getRedirectUrl($context); - if ($model AND $redirectUrl) { + if ($model && $redirectUrl) { $redirectUrl = parse_values($model->getAttributes(), $redirectUrl); } @@ -502,7 +502,7 @@ protected function prepareModelsToSave($model, $saveData) */ protected function setModelAttributes($model, $saveData) { - if (!is_array($saveData) OR !$model) { + if (!is_array($saveData) || !$model) { return; } @@ -510,12 +510,12 @@ protected function setModelAttributes($model, $saveData) $singularTypes = ['belongsTo', 'hasOne', 'morphOne']; foreach ($saveData as $attribute => $value) { - $isNested = ($attribute == 'pivot' OR ( - $model->hasRelation($attribute) AND + $isNested = ($attribute == 'pivot' || ( + $model->hasRelation($attribute) && in_array($model->getRelationType($attribute), $singularTypes) )); - if ($isNested AND is_array($value) AND $model->{$attribute}) { + if ($isNested && is_array($value) && $model->{$attribute}) { $this->setModelAttributes($model->{$attribute}, $value); } elseif ($value !== FormField::NO_SAVE_DATA) { diff --git a/app/admin/actions/ListController.php b/app/admin/actions/ListController.php index 55d3b11856..bb085d49ac 100644 --- a/app/admin/actions/ListController.php +++ b/app/admin/actions/ListController.php @@ -103,7 +103,7 @@ public function index() public function index_onDelete() { $checkedIds = post('checked'); - if (!$checkedIds OR !is_array($checkedIds) OR !count($checkedIds)) { + if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) { flash()->success(lang('admin::lang.list.delete_empty')); return $this->controller->refreshList(); @@ -165,7 +165,7 @@ public function makeLists() */ public function makeList($alias) { - if (!$alias OR !isset($this->listConfig[$alias])) + if (!$alias || !isset($this->listConfig[$alias])) $alias = $this->primaryAlias; $listConfig = $this->controller->getListConfig($alias); @@ -210,7 +210,7 @@ public function makeList($alias) $widget->bindToController(); // Prep the optional toolbar widget - if (isset($this->controller->widgets['toolbar']) AND (isset($listConfig['toolbar']) OR isset($modelConfig['toolbar']))) { + if (isset($this->controller->widgets['toolbar']) && (isset($listConfig['toolbar']) || isset($modelConfig['toolbar']))) { $this->toolbarWidget = $this->controller->widgets['toolbar']; if ($this->toolbarWidget instanceof \Admin\Widgets\Toolbar) $this->toolbarWidget->reInitialize($listConfig['toolbar'] ?? $modelConfig['toolbar']); @@ -266,7 +266,7 @@ public function makeList($alias) public function renderList($alias = null) { - if (is_null($alias) OR !isset($this->listConfig[$alias])) + if (is_null($alias) || !isset($this->listConfig[$alias])) $alias = $this->primaryAlias; $list = []; @@ -290,7 +290,7 @@ public function refreshList($alias = null) $this->makeLists(); } - if (!$alias OR !isset($this->listConfig[$alias])) { + if (!$alias || !isset($this->listConfig[$alias])) { $alias = $this->primaryAlias; } diff --git a/app/admin/actions/LocationAwareController.php b/app/admin/actions/LocationAwareController.php index ac0e9b7030..641c2e1413 100644 --- a/app/admin/actions/LocationAwareController.php +++ b/app/admin/actions/LocationAwareController.php @@ -74,7 +74,7 @@ protected function locationBindEvents() Event::listen('admin.filter.extendQuery', function ($filterWidget, $query, $scope) { if (array_get($scope->config, 'locationAware') === TRUE - AND (bool)$this->getConfig('applyScopeOnListQuery', TRUE) + && (bool)$this->getConfig('applyScopeOnListQuery', TRUE) ) $this->locationApplyScope($query); }); } diff --git a/app/admin/activitytypes/AssigneeUpdated.php b/app/admin/activitytypes/AssigneeUpdated.php index bef9ebb94d..c420e22a67 100644 --- a/app/admin/activitytypes/AssigneeUpdated.php +++ b/app/admin/activitytypes/AssigneeUpdated.php @@ -38,7 +38,7 @@ public static function log(Assignable_logs_model $assignableLog, User $user = nu $recipients = []; foreach ($assignableLog->assignable->listGroupAssignees() as $assignee) { - if ($user AND $assignee->getKey() === $user->staff->getKey()) continue; + if ($user && $assignee->getKey() === $user->staff->getKey()) continue; $recipients[] = $assignee->user; } diff --git a/app/admin/activitytypes/StatusUpdated.php b/app/admin/activitytypes/StatusUpdated.php index bd422b21fa..c77d87f084 100644 --- a/app/admin/activitytypes/StatusUpdated.php +++ b/app/admin/activitytypes/StatusUpdated.php @@ -37,11 +37,11 @@ public static function log(Status_history_model $history, User $user = null) $type = $history->isForOrder() ? self::ORDER_UPDATED_TYPE : self::RESERVATION_UPDATED_TYPE; $recipients = []; - if ($history->object->assignee AND $history->object->assignee->getKey() !== $user->staff->getKey()) + if ($history->object->assignee && $history->object->assignee->getKey() !== $user->staff->getKey()) $recipients[] = $history->object->assignee->user; $statusHistory = $history->object->getLatestStatusHistory(); - if ($history->object->customer AND $statusHistory AND $statusHistory->notify) + if ($history->object->customer && $statusHistory && $statusHistory->notify) $recipients[] = $history->object->customer; activity()->logActivity(new self($type, $history->object, $user), $recipients); diff --git a/app/admin/classes/AdminController.php b/app/admin/classes/AdminController.php index cc529eeed0..1cba0cc43d 100644 --- a/app/admin/classes/AdminController.php +++ b/app/admin/classes/AdminController.php @@ -170,7 +170,7 @@ public function initialize() $toolbar->bindToController(); // Media Manager widget is available on all admin pages - if ($this->currentUser AND $this->currentUser->hasPermission('Admin.MediaManager')) { + if ($this->currentUser && $this->currentUser->hasPermission('Admin.MediaManager')) { $manager = new MediaManager($this, ['alias' => 'mediamanager']); $manager->bindToController(); } @@ -188,7 +188,7 @@ public function remap($action, $params) } // Determine if this request is a public action or authentication is required - $requireAuthentication = !(in_array($action, $this->publicActions) OR !$this->requireAuthentication); + $requireAuthentication = !(in_array($action, $this->publicActions) || !$this->requireAuthentication); // Ensures that a user is logged in, if required if ($requireAuthentication) { @@ -199,7 +199,7 @@ public function remap($action, $params) } // Check that user has permission to view this page - if ($this->requiredPermissions AND !$this->getUser()->hasAnyPermission($this->requiredPermissions)) { + if ($this->requiredPermissions && !$this->getUser()->hasAnyPermission($this->requiredPermissions)) { return Response::make(Request::ajax() ? lang('admin::lang.alert_user_restricted') : View::make('admin::access_denied'), 403 @@ -215,7 +215,7 @@ public function remap($action, $params) } // Execute post handler and AJAX event - if ($handlerResponse = $this->processHandlers() AND $handlerResponse !== TRUE) { + if (($handlerResponse = $this->processHandlers()) && $handlerResponse !== TRUE) { return $handlerResponse; } @@ -280,10 +280,10 @@ protected function execPageAction($action, $params) array_unshift($params, $action); // Execute the action - $result = call_user_func_array([$this, $action], $params); + $result = call_user_func_array([$this, $action], array_values($params)); // Render the controller view if not already loaded - if (is_null($result) AND !$this->suppressView) { + if (is_null($result) && !$this->suppressView) { return $this->makeView($this->fatalError ? 'admin::error' : $action); } @@ -313,7 +313,7 @@ protected function makeMainMenuWidget() */ public function getHandler() { - if (Request::ajax() AND $handler = Request::header('X-IGNITER-REQUEST-HANDLER')) + if (Request::ajax() && $handler = Request::header('X-IGNITER-REQUEST-HANDLER')) return trim($handler); if ($handler = post('_handler')) @@ -465,8 +465,8 @@ protected function runHandler($handler, $params) throw new Exception(sprintf(lang('admin::lang.alert_widget_not_bound_to_controller'), $widgetName)); } - if (($widget = $this->widgets[$widgetName]) AND method_exists($widget, $handlerName)) { - $result = call_user_func_array([$widget, $handlerName], $params); + if (($widget = $this->widgets[$widgetName]) && method_exists($widget, $handlerName)) { + $result = call_user_func_array([$widget, $handlerName], array_values($params)); return $result ?: TRUE; } @@ -476,14 +476,14 @@ protected function runHandler($handler, $params) $pageHandler = $this->action.'_'.$handler; if ($this->methodExists($pageHandler)) { - $result = call_user_func_array([$this, $pageHandler], $params); + $result = call_user_func_array([$this, $pageHandler], array_values($params)); return $result ?: TRUE; } // Process page global handler (onSomething) if ($this->methodExists($handler)) { - $result = call_user_func_array([$this, $handler], $params); + $result = call_user_func_array([$this, $handler], array_values($params)); return $result ?: TRUE; } @@ -494,7 +494,7 @@ protected function runHandler($handler, $params) foreach ((array)$this->widgets as $widget) { if ($widget->methodExists($handler)) { - $result = call_user_func_array([$widget, $handler], $params); + $result = call_user_func_array([$widget, $handler], array_values($params)); return $result ?: TRUE; } diff --git a/app/admin/classes/BaseWidget.php b/app/admin/classes/BaseWidget.php index 165116a721..9e78c80f08 100644 --- a/app/admin/classes/BaseWidget.php +++ b/app/admin/classes/BaseWidget.php @@ -202,7 +202,7 @@ public function getConfig($name = null, $default = null) $result = isset($this->config[$fieldName]) ? $this->config[$fieldName] : $default; foreach ($nameArray as $key) { - if (!is_array($result) OR !array_key_exists($key, $result)) + if (!is_array($result) || !array_key_exists($key, $result)) return $default; $result = $result[$key]; diff --git a/app/admin/classes/FormField.php b/app/admin/classes/FormField.php index 8875b111b5..1cc05df7ee 100644 --- a/app/admin/classes/FormField.php +++ b/app/admin/classes/FormField.php @@ -457,14 +457,14 @@ protected function filterAttributes($attributes, $position = 'field') $attributes = $this->filterTriggerAttributes($attributes, $position); $attributes = $this->filterPresetAttributes($attributes, $position); - if ($position == 'field' AND $this->disabled) { + if ($position == 'field' && $this->disabled) { $attributes += ['disabled' => 'disabled']; } if ($position == 'field' && $this->readOnly) { $attributes += ['readonly' => 'readonly']; - if ($this->type == 'checkbox' OR $this->type == 'switch') { + if ($this->type == 'checkbox' || $this->type == 'switch') { $attributes += ['onclick' => 'return false;']; } } @@ -482,7 +482,7 @@ protected function filterAttributes($attributes, $position = 'field') */ protected function filterTriggerAttributes($attributes, $position = 'field') { - if (!$this->trigger OR !is_array($this->trigger)) { + if (!$this->trigger || !is_array($this->trigger)) { return $attributes; } @@ -491,12 +491,12 @@ protected function filterTriggerAttributes($attributes, $position = 'field') $triggerCondition = array_get($this->trigger, 'condition'); // Apply these to container - if (in_array($triggerAction, ['hide', 'show']) AND $position != 'container') { + if (in_array($triggerAction, ['hide', 'show']) && $position != 'container') { return $attributes; } // Apply these to field/input - if (in_array($triggerAction, ['enable', 'disable', 'empty']) AND $position != 'field') { + if (in_array($triggerAction, ['enable', 'disable', 'empty']) && $position != 'field') { return $attributes; } @@ -529,7 +529,7 @@ protected function filterTriggerAttributes($attributes, $position = 'field') */ protected function filterPresetAttributes($attributes, $position = 'field') { - if (!$this->preset OR $position != 'field') { + if (!$this->preset || $position != 'field') { return $attributes; } @@ -705,7 +705,7 @@ protected function getFieldNameFromData($fieldName, $data, $default = null) // To support relations only the last field should return th // relation value, all others will look up the relation object as normal. foreach ($keyParts as $key) { - if ($result instanceof Model AND $result->hasRelation($key)) { + if ($result instanceof Model && $result->hasRelation($key)) { if ($key == $lastField) { $result = $result->getRelationValue($key) ?: $default; } diff --git a/app/admin/classes/Location.php b/app/admin/classes/Location.php index f7c4ff8c9e..137ce29a32 100644 --- a/app/admin/classes/Location.php +++ b/app/admin/classes/Location.php @@ -28,14 +28,14 @@ public function current() } else { $id = $this->getSession('id'); - if (!$id AND $this->hasOneLocation() AND !$this->getAuth()->isSuperUser()) + if (!$id && $this->hasOneLocation() && !$this->getAuth()->isSuperUser()) $id = $this->getDefaultLocation(); - if ($id AND !$this->isAttachedToAuth($id)) + if ($id && !$this->isAttachedToAuth($id)) $id = $this->getDefaultLocation(); } - if ($id AND $model = $this->getById($id)) + if ($id && $model = $this->getById($id)) $this->setCurrent($model); return $this->model; diff --git a/app/admin/classes/Navigation.php b/app/admin/classes/Navigation.php index 0a5af1fd57..7acbd0f9e6 100644 --- a/app/admin/classes/Navigation.php +++ b/app/admin/classes/Navigation.php @@ -60,7 +60,7 @@ public function getVisibleNavItems() $navItems = $this->filterPermittedNavItems($navItems); foreach ($navItems as $code => &$navItem) { - if (!isset($navItem['child']) OR !count($navItem['child'])) { + if (!isset($navItem['child']) || !count($navItem['child'])) { continue; } @@ -216,7 +216,7 @@ public function registerNavItems($definitions = null, $parent = null) } foreach ($definitions as $name => $definition) { - if (isset($definition['child']) AND count($definition['child'])) { + if (isset($definition['child']) && count($definition['child'])) { $this->registerNavItems($definition['child'], $name); } diff --git a/app/admin/classes/PaymentGateways.php b/app/admin/classes/PaymentGateways.php index 19ea900f27..608a74280a 100644 --- a/app/admin/classes/PaymentGateways.php +++ b/app/admin/classes/PaymentGateways.php @@ -190,7 +190,7 @@ public static function createPartials() foreach ($paymentMethods as $paymentMethod) { $class = $paymentMethod->getGatewayClass(); - if (!$class OR get_parent_class($class) != BasePaymentGateway::class) + if (!$class || get_parent_class($class) != BasePaymentGateway::class) continue; $partialName = 'payregister/'.strtolower(class_basename($class)); diff --git a/app/admin/classes/PermissionManager.php b/app/admin/classes/PermissionManager.php index 37a5900024..6c386f3b6d 100644 --- a/app/admin/classes/PermissionManager.php +++ b/app/admin/classes/PermissionManager.php @@ -85,14 +85,14 @@ public function checkPermission($permissions, $checkPermissions, $checkAll) $matched = FALSE; foreach ($checkPermissions as $permission) { if ($this->checkPermissionStartsWith($permission, $permissions) - OR $this->checkPermissionEndsWith($permission, $permissions) - OR $this->checkPermissionMatches($permission, $permissions) + || $this->checkPermissionEndsWith($permission, $permissions) + || $this->checkPermissionMatches($permission, $permissions) ) $matched = TRUE; - if ($checkAll === FALSE AND $matched === TRUE) + if ($checkAll === FALSE && $matched === TRUE) return TRUE; - if ($checkAll === TRUE AND $matched === FALSE) + if ($checkAll === TRUE && $matched === FALSE) return FALSE; } @@ -101,14 +101,14 @@ public function checkPermission($permissions, $checkPermissions, $checkAll) protected function checkPermissionStartsWith($permission, $permissions) { - if (strlen($permission) > 1 AND ends_with($permission, '*')) { + if (strlen($permission) > 1 && ends_with($permission, '*')) { $checkPermission = substr($permission, 0, -1); foreach ($permissions as $groupPermission => $permitted) { // Let's make sure the available permission starts with our permission if ($checkPermission != $groupPermission - AND starts_with($groupPermission, $checkPermission) - AND $permitted == 1 + && starts_with($groupPermission, $checkPermission) + && $permitted == 1 ) return TRUE; } } @@ -116,14 +116,14 @@ protected function checkPermissionStartsWith($permission, $permissions) protected function checkPermissionEndsWith($permission, $permissions) { - if (strlen($permission) > 1 AND starts_with($permission, '*')) { + if (strlen($permission) > 1 && starts_with($permission, '*')) { $checkPermission = substr($permission, 1); foreach ($permissions as $groupPermission => $permitted) { // Let's make sure the available permission ends with our permission if ($checkPermission != $groupPermission - AND ends_with($groupPermission, $checkPermission) - AND $permitted == 1 + && ends_with($groupPermission, $checkPermission) + && $permitted == 1 ) return TRUE; } } @@ -132,17 +132,17 @@ protected function checkPermissionEndsWith($permission, $permissions) protected function checkPermissionMatches($permission, $permissions) { foreach ($permissions as $groupPermission => $permitted) { - if ((strlen($groupPermission) > 1) AND ends_with($groupPermission, '*')) { + if ((strlen($groupPermission) > 1) && ends_with($groupPermission, '*')) { $checkMergedPermission = substr($groupPermission, 0, -1); // Let's make sure the our permission starts with available permission if ($checkMergedPermission != $permission - AND starts_with($permission, $checkMergedPermission) - AND $permitted == 1 + && starts_with($permission, $checkMergedPermission) + && $permitted == 1 ) return TRUE; } // Match permissions explicitly. - elseif ($permission == $groupPermission AND $permitted == 1) { + elseif ($permission == $groupPermission && $permitted == 1) { return TRUE; } } @@ -159,7 +159,7 @@ public function registerPermissions($owner, array $definitions) } foreach ($definitions as $code => $definition) { - if (!isset($definition['label']) AND isset($definition['description'])) { + if (!isset($definition['label']) && isset($definition['description'])) { $definition['label'] = $definition['description']; unset($definition['description']); } diff --git a/app/admin/classes/ScheduleItem.php b/app/admin/classes/ScheduleItem.php index adb4e8e2d1..d6d2c0cf1b 100644 --- a/app/admin/classes/ScheduleItem.php +++ b/app/admin/classes/ScheduleItem.php @@ -110,7 +110,7 @@ protected function flexible(array $data) $result = []; foreach (Working_hours_model::$weekDays as $key => $weekDay) { $hour = array_get($data, $key, []); - if (isset($hour['open']) AND isset($hour['close'])) { + if (isset($hour['open']) && isset($hour['close'])) { $hour['hours'] = sprintf('%s-%s', $hour['open'], $hour['close']); unset($hour['open'], $hour['close']); } diff --git a/app/admin/classes/ToolbarButton.php b/app/admin/classes/ToolbarButton.php index 14cf3fc32f..5882bd1c73 100644 --- a/app/admin/classes/ToolbarButton.php +++ b/app/admin/classes/ToolbarButton.php @@ -85,7 +85,7 @@ public function getAttributes($htmlBuild = TRUE) foreach ($config as $key => $value) { if (!is_string($value)) continue; - $value = ($key == 'href' AND !preg_match('#^(\w+:)?//#i', $value)) + $value = ($key == 'href' && !preg_match('#^(\w+:)?//#i', $value)) ? admin_url($value) : $value; diff --git a/app/admin/classes/User.php b/app/admin/classes/User.php index 18bcbf33b2..69e6929e35 100644 --- a/app/admin/classes/User.php +++ b/app/admin/classes/User.php @@ -96,7 +96,7 @@ public function register(array $attributes, $activate = FALSE) $staff->user = [ 'username' => $attributes['username'], 'password' => $attributes['password'], - 'super_user' => FALSE, + 'super_user' => $attributes['super_user'] ?? FALSE, 'activate' => $activate, ]; diff --git a/app/admin/classes/UserPanel.php b/app/admin/classes/UserPanel.php index 6646705434..01a22af511 100644 --- a/app/admin/classes/UserPanel.php +++ b/app/admin/classes/UserPanel.php @@ -103,6 +103,11 @@ public function listGroupNames() return $this->user->staff->groups->pluck('staff_group_name')->all(); } + public function getRoleName() + { + return optional($this->user->staff->role)->name; + } + public function listLocations() { return AdminLocation::listLocations()->map(function ($value, $key) { diff --git a/app/admin/controllers/Categories.php b/app/admin/controllers/Categories.php index 08aed0d19f..372edc46c2 100644 --- a/app/admin/controllers/Categories.php +++ b/app/admin/controllers/Categories.php @@ -61,7 +61,7 @@ public function __construct() public function formBeforeSave($model) { - if (!$model->getRgt() OR !$model->getLft()) + if (!$model->getRgt() || !$model->getLft()) $model->fixTree(); if (Categories_model::isBroken()) diff --git a/app/admin/controllers/Customers.php b/app/admin/controllers/Customers.php index 37e478b9a7..edf5cd3323 100644 --- a/app/admin/controllers/Customers.php +++ b/app/admin/controllers/Customers.php @@ -86,7 +86,7 @@ public function edit_onActivate($context, $recordId = null) public function formExtendModel($model) { - if ($model->exists AND !$model->is_activated) { + if ($model->exists && !$model->is_activated) { Template::setButton(lang('admin::lang.customers.button_activate'), [ 'class' => 'btn btn-success pull-right', 'data-request' => 'onActivate', @@ -96,10 +96,10 @@ public function formExtendModel($model) public function formAfterSave($model) { - if (!$model->group OR $model->group->requiresApproval()) + if (!$model->group || $model->group->requiresApproval()) return; - if ($this->status AND !$this->is_activated) + if ($this->status && !$this->is_activated) $model->completeActivation($model->getActivationCode()); } } diff --git a/app/admin/controllers/Locations.php b/app/admin/controllers/Locations.php index 8d8a11c891..ec0b0d4727 100644 --- a/app/admin/controllers/Locations.php +++ b/app/admin/controllers/Locations.php @@ -62,7 +62,7 @@ public function __construct() public function remap($action, $params) { - if ($action != 'settings' AND AdminLocation::check()) + if ($action != 'settings' && AdminLocation::check()) return $this->redirect('locations/settings'); return parent::remap($action, $params); diff --git a/app/admin/controllers/Login.php b/app/admin/controllers/Login.php index f91b3f47f4..627e0f55f0 100644 --- a/app/admin/controllers/Login.php +++ b/app/admin/controllers/Login.php @@ -42,7 +42,7 @@ public function reset() } $code = input('code'); - if (strlen($code) AND !Users_model::whereResetCode(input('code'))->first()) { + if (strlen($code) && !Users_model::whereResetCode(input('code'))->first()) { flash()->error(lang('admin::lang.login.alert_failed_reset')); return $this->redirect('login'); @@ -89,7 +89,7 @@ public function onRequestResetPassword() ]); $staff = Staffs_model::whereStaffEmail(post('email'))->first(); - if ($staff AND $user = $staff->user) { + if ($staff && $user = $staff->user) { if (!$user->resetPassword()) throw new ValidationException(['email' => lang('admin::lang.login.alert_failed_reset')]); $data = [ @@ -119,7 +119,7 @@ public function onResetPassword() $code = array_get($data, 'code'); $user = Users_model::whereResetCode($code)->first(); - if (!$user OR !$user->completeResetPassword($code, post('password'))) + if (!$user || !$user->completeResetPassword($code, post('password'))) throw new ValidationException(['password' => lang('admin::lang.login.alert_failed_reset')]); $data = [ diff --git a/app/admin/controllers/Orders.php b/app/admin/controllers/Orders.php index 2513ebd415..9b02b19ca9 100644 --- a/app/admin/controllers/Orders.php +++ b/app/admin/controllers/Orders.php @@ -78,7 +78,7 @@ public function index_onUpdateStatus() { $model = Orders_model::find((int)post('recordId')); $status = Statuses_model::find((int)post('statusId')); - if (!$model OR !$status) + if (!$model || !$status) return; if ($record = $model->addStatusHistory($status)) diff --git a/app/admin/controllers/Payments.php b/app/admin/controllers/Payments.php index 9ca4b37771..4109ff5ce1 100644 --- a/app/admin/controllers/Payments.php +++ b/app/admin/controllers/Payments.php @@ -152,7 +152,7 @@ public function formValidate($model, $form) ['status', 'lang:admin::lang.label_status', 'required|integer'], ]; - if ($form->model->exists AND ($mergeRules = $form->model->getConfigRules())) + if ($form->model->exists && ($mergeRules = $form->model->getConfigRules())) array_push($rules, ...$mergeRules); return $this->validatePasses($form->getSaveData(), $rules); diff --git a/app/admin/controllers/Reservations.php b/app/admin/controllers/Reservations.php index 6c71a438a3..b96572a21e 100644 --- a/app/admin/controllers/Reservations.php +++ b/app/admin/controllers/Reservations.php @@ -96,7 +96,7 @@ public function index_onUpdateStatus() { $model = Reservations_model::find((int)post('recordId')); $status = Statuses_model::find((int)post('statusId')); - if (!$model OR !$status) + if (!$model || !$status) return; if ($record = $model->addStatusHistory($status)) diff --git a/app/admin/controllers/Staffs.php b/app/admin/controllers/Staffs.php index 9272cd54fb..e1d1e13966 100644 --- a/app/admin/controllers/Staffs.php +++ b/app/admin/controllers/Staffs.php @@ -75,7 +75,7 @@ public function account_onSave() $usernameChanged = $this->currentUser->username != post('Staff[user][username]'); $passwordChanged = strlen(post('Staff[user][password]')); $languageChanged = $this->currentUser->language != post('Staff[language_id]'); - if ($usernameChanged OR $passwordChanged OR $languageChanged) { + if ($usernameChanged || $passwordChanged || $languageChanged) { $this->currentUser->reload()->reloadRelations(); AdminAuth::login($this->currentUser, TRUE); } diff --git a/app/admin/dashboardwidgets/onboarding/onboarding.blade.php b/app/admin/dashboardwidgets/onboarding/onboarding.blade.php index c71afe71e7..e13c771e76 100644 --- a/app/admin/dashboardwidgets/onboarding/onboarding.blade.php +++ b/app/admin/dashboardwidgets/onboarding/onboarding.blade.php @@ -3,7 +3,7 @@
@foreach($onboarding->listSteps() as $step) - @if($completed = $step->completed AND $completed()) + @if(($completed = $step->completed) && $completed())
@lang($step->label) @@ -19,7 +19,7 @@ @lang($step->description) @endif - @endforeach + @endforeach
diff --git a/app/admin/database/migrations/2021_10_22_010000_make_primary_key_bigint_all_tables.php b/app/admin/database/migrations/2021_10_22_010000_make_primary_key_bigint_all_tables.php new file mode 100644 index 0000000000..680ca0e467 --- /dev/null +++ b/app/admin/database/migrations/2021_10_22_010000_make_primary_key_bigint_all_tables.php @@ -0,0 +1,55 @@ + 'address_id', + 'allergens' => 'allergen_id', + 'assignable_logs' => 'id', + 'categories' => 'category_id', + 'customer_groups' => 'customer_group_id', + 'customers' => 'customer_id', + 'location_areas' => 'area_id', + 'locations' => 'location_id', + 'mealtimes' => 'mealtime_id', + 'menu_item_option_values' => 'menu_option_value_id', + 'menu_item_options' => 'menu_option_id', + 'menu_option_values' => 'option_value_id', + 'menu_options' => 'option_id', + 'menus' => 'menu_id', + 'menus_specials' => 'special_id', + 'order_menu_options' => 'order_option_id', + 'order_menus' => 'order_menu_id', + 'order_totals' => 'order_total_id', + 'orders' => 'order_id', + 'payment_logs' => 'payment_log_id', + 'payment_profiles' => 'payment_profile_id', + 'payments' => 'payment_id', + 'reservations' => 'reservation_id', + 'staff_groups' => 'staff_group_id', + 'staff_roles' => 'staff_role_id', + 'staffs' => 'staff_id', + 'status_history' => 'status_history_id', + 'statuses' => 'status_id', + 'tables' => 'table_id', + 'user_preferences' => 'id', + 'users' => 'user_id', + ] as $table => $key) { + Schema::table($table, function (Blueprint $table) use ($key) { + $table->unsignedBigInteger($key, TRUE)->change(); + }); + } + } + + public function down() + { + } +} diff --git a/app/admin/database/migrations/2021_10_25_010000_add_foreign_key_constraints_to_tables.php b/app/admin/database/migrations/2021_10_25_010000_add_foreign_key_constraints_to_tables.php new file mode 100644 index 0000000000..98acedf73c --- /dev/null +++ b/app/admin/database/migrations/2021_10_25_010000_add_foreign_key_constraints_to_tables.php @@ -0,0 +1,192 @@ +getForeignConstraints() as $tableName => $constraints) { + foreach ($constraints as $options) { + $this->addForeignKey($tableName, $options); + } + } + + Schema::enableForeignKeyConstraints(); + } + + public function down() + { + foreach ($this->getForeignConstraints() as $tableName => $constraints) { + foreach ($constraints as $options) { + $this->dropForeignKey($tableName, $options); + } + } + } + + protected function addForeignKey($tableName, $options) + { + Schema::table($tableName, function (Blueprint $table) use ($options) { + $foreignTableName = $options[0]; + + $keys = (array)$options[1]; + $foreignKey = $keys[0]; + $parentKey = $keys[1] ?? $keys[0]; + + $blueprint = $table->foreignId($foreignKey); + + if (array_get($options, 'nullable', TRUE)) + $blueprint->nullable(); + + $blueprint->change(); + + $blueprint = $table->foreign($foreignKey)->references($parentKey)->on($foreignTableName); + + if (array_get($options, 'nullOnDelete')) + $blueprint->nullOnDelete(); + + if (array_get($options, 'cascadeOnDelete')) + $blueprint->cascadeOnDelete(); + + if (array_get($options, 'cascadeOnUpdate', TRUE)) + $blueprint->cascadeOnUpdate(); + }); + } + + protected function dropForeignKey($tableName, $options) + { + try { + Schema::table($tableName, function (Blueprint $table) use ($options) { + $keys = (array)$options[1]; + $foreignKey = $keys[0]; + + $table->dropForeign([$foreignKey]); + }); + } + catch (\Exception $ex) { + Log::error($ex); + } + } + + protected function getForeignConstraints(): array + { + return [ + 'addresses' => [ + ['customers', 'customer_id', 'nullOnDelete' => TRUE], + ['countries', 'country_id', 'nullOnDelete' => TRUE], + ], + 'allergenables' => [ + ['allergens', 'allergen_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'assignable_logs' => [ + ['staffs', ['assignee_id', 'staff_id'], 'nullable' => FALSE, 'nullOnDelete' => TRUE], + ['staff_groups', ['assignee_group_id', 'staff_group_id'], 'nullable' => FALSE, 'nullOnDelete' => TRUE], + ['statuses', ['status_id', 'status_id'], 'nullable' => FALSE, 'nullOnDelete' => TRUE], + ], + 'categories' => [ + ['categories', ['parent_id', 'category_id'], 'nullOnDelete' => TRUE], + ], + 'customers' => [ + ['addresses', 'address_id', 'nullOnDelete' => TRUE], + ['customer_groups', 'customer_group_id', 'nullOnDelete' => TRUE], + ], + 'location_areas' => [ + ['locations', 'location_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'locationables' => [ + ['locations', 'location_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'locations' => [ + ['countries', ['location_country_id', 'country_id'], 'cascadeOnDelete' => TRUE], + ], + 'menu_categories' => [ + ['menus', 'menu_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['categories', 'category_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'menu_item_option_values' => [ + ['menu_item_options', 'menu_option_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['menu_option_values', 'option_value_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'menu_item_options' => [ + ['menus', 'menu_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['menu_options', 'option_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'menu_mealtimes' => [ + ['menus', 'menu_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['mealtimes', 'mealtime_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'menu_option_values' => [ + ['menu_options', 'option_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'menus_specials' => [ + ['menus', 'menu_id', 'cascadeOnDelete' => TRUE], + ], + 'order_menu_options' => [ + ['orders', 'order_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['order_menus', 'order_menu_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'order_menus' => [ + ['orders', 'order_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['menus', 'menu_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'order_totals' => [ + ['orders', 'order_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'orders' => [ + ['customers', 'customer_id', 'nullOnDelete' => TRUE], + ['locations', 'location_id', 'nullOnDelete' => TRUE], + ['addresses', 'address_id', 'nullOnDelete' => TRUE], + ['statuses', 'status_id', 'nullOnDelete' => TRUE], + ['staffs', ['assignee_id', 'staff_id'], 'nullOnDelete' => TRUE], + ['staff_groups', ['assignee_group_id', 'staff_group_id'], 'nullOnDelete' => TRUE], + ], + 'payment_logs' => [ + ['orders', 'order_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'payment_profiles' => [ + ['customers', 'customer_id', 'cascadeOnDelete' => TRUE], + ['payments', 'payment_id', 'cascadeOnDelete' => TRUE], + ], + 'reservation_tables' => [ + ['reservations', 'reservation_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['tables', 'table_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'reservations' => [ + ['tables', 'table_id', 'nullOnDelete' => TRUE], + ['customers', 'customer_id', 'nullOnDelete' => TRUE], + ['locations', 'location_id', 'nullOnDelete' => TRUE], + ['statuses', 'status_id', 'nullOnDelete' => TRUE], + ['staffs', ['assignee_id', 'staff_id'], 'nullOnDelete' => TRUE], + ['staff_groups', ['assignee_group_id', 'staff_group_id'], 'nullOnDelete' => TRUE], + ], + 'staffs' => [ + ['staff_roles', 'staff_role_id', 'nullOnDelete' => TRUE], + ['languages', 'language_id', 'nullOnDelete' => TRUE], + ], + 'staffs_groups' => [ + ['staffs', 'staff_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ['staff_groups', 'staff_group_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'status_history' => [ + ['staffs', 'staff_id', 'nullOnDelete' => TRUE], + ['statuses', 'status_id', 'nullOnDelete' => TRUE], + ], + 'user_preferences' => [ + ['users', 'user_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'users' => [ + ['staffs', 'staff_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + 'working_hours' => [ + ['locations', 'location_id', 'nullable' => FALSE, 'cascadeOnDelete' => TRUE], + ], + ]; + } +} diff --git a/app/admin/formwidgets/Connector.php b/app/admin/formwidgets/Connector.php index 1546f5c975..8c665230aa 100644 --- a/app/admin/formwidgets/Connector.php +++ b/app/admin/formwidgets/Connector.php @@ -90,7 +90,7 @@ public function initialize() $fieldName = $this->formField->getName(FALSE); $this->sortableInputName = self::SORT_PREFIX.$fieldName; - if ($this->formField->disabled OR $this->formField->readOnly) { + if ($this->formField->disabled || $this->formField->readOnly) { $this->previewMode = TRUE; } } diff --git a/app/admin/formwidgets/DataTable.php b/app/admin/formwidgets/DataTable.php index 92c7726077..0b75a23f9f 100644 --- a/app/admin/formwidgets/DataTable.php +++ b/app/admin/formwidgets/DataTable.php @@ -172,7 +172,7 @@ public function getDataTableOptions($field, $data) { $methodName = 'get'.studly_case($this->fieldName).'DataTableOptions'; - if (!$this->model->methodExists($methodName) AND !$this->model->methodExists('getDataTableOptions')) { + if (!$this->model->methodExists($methodName) && !$this->model->methodExists('getDataTableOptions')) { throw new Exception(sprintf(lang('admin::lang.alert_missing_method'), 'getDataTableOptions', get_class($this->model))); } diff --git a/app/admin/formwidgets/DatePicker.php b/app/admin/formwidgets/DatePicker.php index a74fded4a0..b6d51f40a7 100644 --- a/app/admin/formwidgets/DatePicker.php +++ b/app/admin/formwidgets/DatePicker.php @@ -147,7 +147,7 @@ public function prepareVars() public function getSaveValue($value) { - if ($this->formField->disabled OR $this->formField->hidden) { + if ($this->formField->disabled || $this->formField->hidden) { return FormField::NO_SAVE_DATA; } diff --git a/app/admin/formwidgets/MapArea.php b/app/admin/formwidgets/MapArea.php index 121b30f90b..c0e048381d 100644 --- a/app/admin/formwidgets/MapArea.php +++ b/app/admin/formwidgets/MapArea.php @@ -254,7 +254,7 @@ protected function getMapAreas() $result = []; foreach ($loadValue as $key => $area) { - if (!isset($area['color']) OR !strlen($area['color'])) { + if (!isset($area['color']) || !strlen($area['color'])) { $index = min($key, count($this->areaColors)); $area['color'] = $this->areaColors[$index] ?? $this->areaColors[0]; } diff --git a/app/admin/formwidgets/MarkdownEditor.php b/app/admin/formwidgets/MarkdownEditor.php index 50c2fde051..706060442f 100644 --- a/app/admin/formwidgets/MarkdownEditor.php +++ b/app/admin/formwidgets/MarkdownEditor.php @@ -32,7 +32,7 @@ public function initialize() 'mode', ]); - if ($this->formField->disabled OR $this->formField->readOnly) { + if ($this->formField->disabled || $this->formField->readOnly) { $this->previewMode = TRUE; } } diff --git a/app/admin/formwidgets/MediaFinder.php b/app/admin/formwidgets/MediaFinder.php index c5c392d4e8..d74a5d8c65 100644 --- a/app/admin/formwidgets/MediaFinder.php +++ b/app/admin/formwidgets/MediaFinder.php @@ -148,7 +148,7 @@ public function getMediaThumb($media) public function onLoadAttachmentConfig() { - if (!$this->useAttachment OR !$mediaId = post('media_id')) + if (!$this->useAttachment || !$mediaId = post('media_id')) return; if (!in_array(HasMedia::class, class_uses_recursive(get_class($this->model)))) @@ -166,7 +166,7 @@ public function onLoadAttachmentConfig() public function onSaveAttachmentConfig() { - if (!$this->useAttachment OR !$mediaId = post('media_id')) + if (!$this->useAttachment || !$mediaId = post('media_id')) return; if (!in_array(HasMedia::class, class_uses_recursive(get_class($this->model)))) @@ -191,7 +191,7 @@ public function onSaveAttachmentConfig() public function onRemoveAttachment() { - if (!$this->useAttachment OR !$mediaId = post('media_id')) + if (!$this->useAttachment || !$mediaId = post('media_id')) return; if (!in_array(HasMedia::class, class_uses_recursive(get_class($this->model)))) @@ -235,7 +235,7 @@ public function onAddAttachment() public function getLoadValue() { $value = parent::getLoadValue(); - if (!is_array($value) AND !$value instanceof Collection) + if (!is_array($value) && !$value instanceof Collection) $value = [$value]; if (is_array($value)) @@ -250,7 +250,7 @@ public function getLoadValue() public function getSaveValue($value) { - if ($this->useAttachment OR $this->formField->disabled OR $this->formField->hidden) { + if ($this->useAttachment || $this->formField->disabled || $this->formField->hidden) { return FormField::NO_SAVE_DATA; } diff --git a/app/admin/formwidgets/RecordEditor.php b/app/admin/formwidgets/RecordEditor.php index 3b8d15aa99..f75bd1c541 100644 --- a/app/admin/formwidgets/RecordEditor.php +++ b/app/admin/formwidgets/RecordEditor.php @@ -200,7 +200,7 @@ protected function getRecordEditorOptions() $model = $this->createFormModel(); $methodName = 'get'.studly_case($this->fieldName).'RecordEditorOptions'; - if (!$model->methodExists($methodName) AND !$model->methodExists('getRecordEditorOptions')) { + if (!$model->methodExists($methodName) && !$model->methodExists('getRecordEditorOptions')) { throw new ApplicationException(sprintf(lang('admin::lang.alert_missing_method'), 'getRecordEditorOptions', get_class($model))); } diff --git a/app/admin/formwidgets/Relation.php b/app/admin/formwidgets/Relation.php index affd556609..75e7d54b68 100644 --- a/app/admin/formwidgets/Relation.php +++ b/app/admin/formwidgets/Relation.php @@ -90,7 +90,7 @@ public function render() public function getSaveValue($value) { - if ($this->formField->disabled OR $this->formField->hidden) { + if ($this->formField->disabled || $this->formField->hidden) { return FormField::NO_SAVE_DATA; } @@ -211,7 +211,7 @@ protected function getRelationObject() { [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom); - if (!$model OR !$model->hasRelation($attribute)) { + if (!$model || !$model->hasRelation($attribute)) { throw new Exception(sprintf(lang('admin::lang.alert_missing_model_definition'), get_class($this->model), $this->valueFrom diff --git a/app/admin/formwidgets/Repeater.php b/app/admin/formwidgets/Repeater.php index 906837d2ac..3c4ec6a473 100644 --- a/app/admin/formwidgets/Repeater.php +++ b/app/admin/formwidgets/Repeater.php @@ -150,7 +150,7 @@ public function getVisibleColumns() $columns = []; foreach ($this->itemDefinitions['fields'] as $name => $field) { - if (isset($field['type']) AND $field['type'] == 'hidden') + if (isset($field['type']) && $field['type'] == 'hidden') continue; $columns[$name] = $field['label'] ?? null; @@ -168,13 +168,13 @@ public function getFormWidgetTemplate() protected function processSaveValue($value) { - if (!is_array($value) OR !$value) return $value; + if (!is_array($value) || !$value) return $value; $sortedIndexes = (array)post($this->sortableInputName); $sortedIndexes = array_flip($sortedIndexes); foreach ($value as $index => &$data) { - if ($sortedIndexes AND $this->sortable) + if ($sortedIndexes && $this->sortable) $data[$this->sortColumnName] = $sortedIndexes[$index]; $items[$index] = $data; @@ -258,7 +258,7 @@ protected function getRelationModel() { [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom); - if (!$model instanceof Model OR !$model->hasRelation($attribute)) { + if (!$model instanceof Model || !$model->hasRelation($attribute)) { return $this->model; } diff --git a/app/admin/formwidgets/StatusEditor.php b/app/admin/formwidgets/StatusEditor.php index 66525432d0..37ddef5354 100644 --- a/app/admin/formwidgets/StatusEditor.php +++ b/app/admin/formwidgets/StatusEditor.php @@ -159,7 +159,7 @@ public function onSaveRecord() try { $this->validateAfter(function ($validator) use ($context, $recordId, $keyFrom) { - if ($this->isStatusMode AND $recordId == $this->model->{$keyFrom}) { + if ($this->isStatusMode && $recordId == $this->model->{$keyFrom}) { $validator->errors()->add($keyFrom, sprintf( lang('admin::lang.statuses.alert_already_added'), $context, $context diff --git a/app/admin/formwidgets/colorpicker/colorpicker.blade.php b/app/admin/formwidgets/colorpicker/colorpicker.blade.php index b060bd91e9..a0473cab5f 100644 --- a/app/admin/formwidgets/colorpicker/colorpicker.blade.php +++ b/app/admin/formwidgets/colorpicker/colorpicker.blade.php @@ -11,7 +11,7 @@ class="input-group control-colorpicker" name="{{ $name }}" class="form-control" value="{{ $value }}" - {!! ($this->disabled OR $this->previewMode) ? 'disabled="disabled"' : '' !!} + {!! ($this->disabled || $this->previewMode) ? 'disabled="disabled"' : '' !!} {!! ($this->readOnly) ? 'readonly="readonly"' : '' !!} /> diff --git a/app/admin/formwidgets/connector/connector.blade.php b/app/admin/formwidgets/connector/connector.blade.php index 572f990d94..7ee1bac48d 100644 --- a/app/admin/formwidgets/connector/connector.blade.php +++ b/app/admin/formwidgets/connector/connector.blade.php @@ -5,7 +5,7 @@ class="field-connector" data-alias="{{ $this->alias }}" data-sortable-container="#{{ $this->getId('items') }}" data-sortable-handle=".{{ $this->getId('items') }}-handle" - data-editable="{{ ($this->previewMode OR !$this->editable) ? 'false' : 'true' }}" + data-editable="{{ ($this->previewMode || !$this->editable) ? 'false' : 'true' }}" >
- @if (!$this->previewMode AND $sortable) + @if (!$this->previewMode && $sortable)
- @if (!$this->previewMode AND $sortable) + @if (!$this->previewMode && $sortable)
- +
@endif diff --git a/app/admin/formwidgets/mediafinder/image_inline.blade.php b/app/admin/formwidgets/mediafinder/image_inline.blade.php index 84a8bf4143..57075fb50e 100644 --- a/app/admin/formwidgets/mediafinder/image_inline.blade.php +++ b/app/admin/formwidgets/mediafinder/image_inline.blade.php @@ -13,7 +13,7 @@ class="img-responsive"
{{ $this->getMediaName($mediaItem) }} - @if (!$this->previewMode AND $sortable) + @if (!$this->previewMode && $sortable) @endif - @if (!$this->previewMode AND $showRemoveButton) + @if (!$this->previewMode && $showRemoveButton) @endif @foreach ($this->getVisibleColumns() as $label) @@ -34,7 +34,7 @@ class="table {{ ($sortable) ? 'is-sortable' : '' }} mb-0"> @endforelse - @if ($showAddButton AND !$this->previewMode) + @if ($showAddButton && !$this->previewMode) diff --git a/app/admin/formwidgets/repeater/repeater_item.blade.php b/app/admin/formwidgets/repeater/repeater_item.blade.php index 2b39293636..7438d0902f 100644 --- a/app/admin/formwidgets/repeater/repeater_item.blade.php +++ b/app/admin/formwidgets/repeater/repeater_item.blade.php @@ -1,7 +1,7 @@ - @if (!$this->previewMode AND $sortable) + @if (!$this->previewMode && $sortable)
@@ -10,7 +10,7 @@ class="repeater-item" data-item-index="{{ $indexValue }}"> @endif - @if (!$this->previewMode AND $showRemoveButton) + @if (!$this->previewMode && $showRemoveButton) causer instanceof Users_model) $prefix = ''.lang('system::lang.activities.activity_system').' '; - if ($activity->causer AND $activity->causer->user_id == AdminAuth::getId()) + if ($activity->causer && $activity->causer->user_id == AdminAuth::getId()) $prefix = ''.ucfirst($self).' '; return $prefix.lang($line); @@ -30,11 +30,11 @@ public static function attachAssignedPlaceholders($line, Activity $activity) if (!$activity->causer instanceof Users_model) $prefix = ''.lang('system::lang.activities.activity_system').' '; - if ($activity->causer AND $activity->causer->user_id == AdminAuth::getId()) + if ($activity->causer && $activity->causer->user_id == AdminAuth::getId()) $prefix = ''.ucfirst($self).' '; $assigneeId = $activity->properties->get('assignee_id'); - if (!$assigneeId AND strlen($activity->properties->get('assignee_group_id'))) { + if (!$assigneeId && strlen($activity->properties->get('assignee_group_id'))) { $suffix = ' :properties.assignee_group_name'; } elseif ($assigneeId == optional(AdminAuth::staff())->getKey()) { diff --git a/app/admin/middleware/LogUserLastSeen.php b/app/admin/middleware/LogUserLastSeen.php index 7f63b6d665..c989272284 100644 --- a/app/admin/middleware/LogUserLastSeen.php +++ b/app/admin/middleware/LogUserLastSeen.php @@ -13,7 +13,7 @@ class LogUserLastSeen { public function handle($request, Closure $next) { - if (App::hasDatabase() AND AdminAuth::check()) { + if (App::hasDatabase() && AdminAuth::check()) { $cacheKey = 'is-online-user-'.AdminAuth::getId(); $expireAt = Carbon::now()->addMinutes(2); Cache::remember($cacheKey, $expireAt, function () { diff --git a/app/admin/models/Coupons_history_model.php b/app/admin/models/Coupons_history_model.php index cf29b64349..5fffacea49 100644 --- a/app/admin/models/Coupons_history_model.php +++ b/app/admin/models/Coupons_history_model.php @@ -47,7 +47,7 @@ class Coupons_history_model extends Model public function getCustomerNameAttribute($value) { - return ($this->customer AND $this->customer->exists) ? $this->customer->full_name : $value; + return ($this->customer && $this->customer->exists) ? $this->customer->full_name : $value; } public function scopeIsEnabled($query) diff --git a/app/admin/models/Coupons_model.php b/app/admin/models/Coupons_model.php index 97ff040abb..6e4a43a24f 100644 --- a/app/admin/models/Coupons_model.php +++ b/app/admin/models/Coupons_model.php @@ -153,7 +153,7 @@ public function hasRestriction($orderType) public function hasLocationRestriction($locationId) { - if (!$this->locations OR $this->locations->isEmpty()) + if (!$this->locations || $this->locations->isEmpty()) return FALSE; $locationKeyColumn = $this->locations()->getModel()->qualifyColumn('location_id'); @@ -163,12 +163,12 @@ public function hasLocationRestriction($locationId) public function hasReachedMaxRedemption() { - return $this->redemptions AND $this->redemptions <= $this->countRedemptions(); + return $this->redemptions && $this->redemptions <= $this->countRedemptions(); } public function customerHasMaxRedemption(User $user) { - return $this->customer_redemptions AND $this->customer_redemptions <= $this->countCustomerRedemptions($user->getKey()); + return $this->customer_redemptions && $this->customer_redemptions <= $this->countCustomerRedemptions($user->getKey()); } public function countRedemptions() diff --git a/app/admin/models/Customers_model.php b/app/admin/models/Customers_model.php index ab0c78a1b9..1016f78ccc 100644 --- a/app/admin/models/Customers_model.php +++ b/app/admin/models/Customers_model.php @@ -95,10 +95,10 @@ public function scopeIsEnabled($query) public function beforeLogin() { - if (!$this->group OR !$this->group->requiresApproval()) + if (!$this->group || !$this->group->requiresApproval()) return; - if ($this->is_activated AND $this->status) + if ($this->is_activated && $this->status) return; throw new Exception(sprintf( @@ -206,7 +206,7 @@ public function saveCustomerGuestOrder() { $query = FALSE; - if (is_numeric($this->customer_id) AND !empty($this->email)) { + if (is_numeric($this->customer_id) && !empty($this->email)) { $customer_id = $this->customer_id; $customer_email = $this->email; $update = ['customer_id' => $customer_id]; @@ -216,7 +216,7 @@ public function saveCustomerGuestOrder() foreach ($orders as $row) { if (empty($row['order_id'])) continue; - if ($row['order_type'] == '1' AND !empty($row['address_id'])) { + if ($row['order_type'] == '1' && !empty($row['address_id'])) { Addresses_model::where('address_id', $row['address_id'])->update($update); } } diff --git a/app/admin/models/Locations_model.php b/app/admin/models/Locations_model.php index 435f50503a..663114c207 100644 --- a/app/admin/models/Locations_model.php +++ b/app/admin/models/Locations_model.php @@ -91,10 +91,10 @@ public static function onboardingIsComplete() return FALSE; return isset($model->getAddress()['location_lat']) - AND isset($model->getAddress()['location_lng']) - AND ($model->hasDelivery() OR $model->hasCollection()) - AND isset($model->options['hours']) - AND $model->delivery_areas->where('is_default', 1)->count() > 0; + && isset($model->getAddress()['location_lng']) + && ($model->hasDelivery() || $model->hasCollection()) + && isset($model->options['hours']) + && $model->delivery_areas->where('is_default', 1)->count() > 0; } public static function addSortingColumns($newColumns) @@ -144,7 +144,7 @@ public function scopeListFrontEnd($query, array $options = []) 'hasCollection' => null, ], $options)); - if ($latitude AND $longitude) { + if ($latitude && $longitude) { $query->selectDistance($latitude, $longitude); } @@ -274,7 +274,7 @@ public function listAvailablePayments() $paymentGateways = Payments_model::listPayments(); foreach ($paymentGateways as $payment) { - if ($payments AND !in_array($payment->code, $payments)) continue; + if ($payments && !in_array($payment->code, $payments)) continue; $result[$payment->code] = $payment; } diff --git a/app/admin/models/Menu_item_option_values_model.php b/app/admin/models/Menu_item_option_values_model.php index 1c7805f2a4..377b8cb820 100644 --- a/app/admin/models/Menu_item_option_values_model.php +++ b/app/admin/models/Menu_item_option_values_model.php @@ -53,6 +53,8 @@ class Menu_item_option_values_model extends Model ['quantity', 'admin::lang.menus.label_option_qty', 'numeric'], ]; + public $timestamps = TRUE; + public function getOptionValueIdOptions() { if (!$optionId = optional($this->menu_option)->option_id) @@ -75,7 +77,7 @@ public function getNameAttribute() public function getPriceAttribute() { - if (is_null($this->new_price) AND $this->option_value) + if (is_null($this->new_price) && $this->option_value) return $this->option_value->price; return $this->new_price; diff --git a/app/admin/models/Menu_item_options_model.php b/app/admin/models/Menu_item_options_model.php index e8f64fc4e8..0a51e09f70 100644 --- a/app/admin/models/Menu_item_options_model.php +++ b/app/admin/models/Menu_item_options_model.php @@ -66,6 +66,8 @@ class Menu_item_options_model extends Model public $with = ['option']; + public $timestamps = TRUE; + public function getOptionNameAttribute() { return optional($this->option)->option_name; diff --git a/app/admin/models/Menus_model.php b/app/admin/models/Menus_model.php index d13d8b6868..dfc8be3624 100644 --- a/app/admin/models/Menus_model.php +++ b/app/admin/models/Menus_model.php @@ -108,7 +108,7 @@ public function scopeListFrontEnd($query, $options = []) $searchableFields = ['menu_name', 'menu_description']; - if (strlen($location) AND is_numeric($location)) { + if (strlen($location) && is_numeric($location)) { $query->whereHasOrDoesntHaveLocation($location); $query->with(['categories' => function ($q) use ($location) { $q->whereHasOrDoesntHaveLocation($location); diff --git a/app/admin/models/Menus_specials_model.php b/app/admin/models/Menus_specials_model.php index 110665ad0a..8ec9889e3b 100644 --- a/app/admin/models/Menus_specials_model.php +++ b/app/admin/models/Menus_specials_model.php @@ -43,7 +43,7 @@ public static function getRecurringEveryOptions() public function getPrettyEndDateAttribute() { - if ($this->isRecurring() OR !$this->end_date) + if ($this->isRecurring() || !$this->end_date) return null; return $this->end_date->format(lang('system::lang.php.date_time_format')); @@ -69,7 +69,7 @@ public function active() public function daysRemaining() { - if ($this->validity != 'period' OR !$this->end_date->greaterThan(Carbon::now())) + if ($this->validity != 'period' || !$this->end_date->greaterThan(Carbon::now())) return 0; return $this->end_date->diffForHumans(); diff --git a/app/admin/models/Orders_model.php b/app/admin/models/Orders_model.php index c3625fb0c4..bd1876a232 100644 --- a/app/admin/models/Orders_model.php +++ b/app/admin/models/Orders_model.php @@ -160,9 +160,10 @@ public function scopeListFrontEnd($query, $options = []) $query->search($search, $searchableFields); } - if ($startDateTime = array_get($dateTimeFilter, 'orderDateTime.startAt', FALSE) AND $endDateTime = array_get($dateTimeFilter, 'orderDateTime.endAt', FALSE)) { + $startDateTime = array_get($dateTimeFilter, 'orderDateTime.startAt', FALSE); + $endDateTime = array_get($dateTimeFilter, 'orderDateTime.endAt', FALSE); + if ($startDateTime && $endDateTime) $query = $this->scopeWhereBetweenOrderDateTime($query, Carbon::parse($startDateTime)->format('Y-m-d H:i:s'), Carbon::parse($endDateTime)->format('Y-m-d H:i:s')); - } $this->fireEvent('model.extendListFrontEndQuery', [$query]); @@ -198,7 +199,7 @@ public function getOrderTypeNameAttribute() public function getOrderDatetimeAttribute($value) { if (!isset($this->attributes['order_date']) - AND !isset($this->attributes['order_time']) + && !isset($this->attributes['order_time']) ) return null; return make_carbon($this->attributes['order_date']) @@ -233,7 +234,7 @@ public function isCompleted() */ public function isPaymentProcessed() { - return $this->processed AND !empty($this->status_id); + return $this->processed && !empty($this->status_id); } public function isDeliveryType() @@ -310,7 +311,7 @@ protected function createHash() public function mailGetRecipients($type) { $emailSetting = setting('order_email'); - is_array($emailSetting) OR $emailSetting = []; + is_array($emailSetting) || $emailSetting = []; $recipients = []; if (in_array($type, $emailSetting)) { diff --git a/app/admin/models/Payments_model.php b/app/admin/models/Payments_model.php index b8ae0604b4..c53b21db2c 100644 --- a/app/admin/models/Payments_model.php +++ b/app/admin/models/Payments_model.php @@ -145,7 +145,7 @@ public function applyGatewayClass($class = null) $class = null; } - if ($class AND !$this->isClassExtendedWith($class)) { + if ($class && !$this->isClassExtendedWith($class)) { $this->extendClassWith($class); } diff --git a/app/admin/models/Reservations_model.php b/app/admin/models/Reservations_model.php index 64caea19f1..6b7e6de659 100644 --- a/app/admin/models/Reservations_model.php +++ b/app/admin/models/Reservations_model.php @@ -156,9 +156,10 @@ public function scopeListFrontEnd($query, $options = []) $query->search($search, $searchableFields); } - if ($startDateTime = array_get($dateTimeFilter, 'reservationDateTime.startAt', FALSE) AND $endDateTime = array_get($dateTimeFilter, 'reservationDateTime.endAt', FALSE)) { + $startDateTime = array_get($dateTimeFilter, 'reservationDateTime.startAt', FALSE); + $endDateTime = array_get($dateTimeFilter, 'reservationDateTime.endAt', FALSE); + if ($startDateTime && $endDateTime) $query = $this->scopeWhereBetweenReservationDateTime($query, Carbon::parse($startDateTime)->format('Y-m-d H:i:s'), Carbon::parse($endDateTime)->format('Y-m-d H:i:s')); - } $this->fireEvent('model.extendListFrontEndQuery', [$query]); @@ -200,7 +201,7 @@ public function getDurationAttribute($value) if (!$location = $this->location) return $value; - return $location->getOption('reservation_stay_time'); + return $location->getReservationStayTime(); } public function getReserveEndTimeAttribute($value) @@ -217,7 +218,7 @@ public function getReserveEndTimeAttribute($value) public function getReservationDatetimeAttribute($value) { if (!isset($this->attributes['reserve_date']) - AND !isset($this->attributes['reserve_time']) + && !isset($this->attributes['reserve_time']) ) return null; return make_carbon($this->attributes['reserve_date']) @@ -244,7 +245,7 @@ public function getTableNameAttribute() public function setDurationAttribute($value) { if (empty($value)) - $value = optional($this->location)->getOption('reservation_stay_time') ?? $value; + $value = optional($this->location()->first())->getReservationStayTime(); $this->attributes['duration'] = $value; } @@ -324,7 +325,7 @@ public function isReservedAllDay() { $diffInMinutes = $this->reservation_datetime->diffInMinutes($this->reservation_end_datetime); - return $diffInMinutes >= (60 * 23) OR $diffInMinutes == 0; + return $diffInMinutes >= (60 * 23) || $diffInMinutes == 0; } public function getOccasionOptions() @@ -392,7 +393,7 @@ public function addReservationTables(array $tableIds = []) public function mailGetRecipients($type) { $emailSetting = setting('reservation_email', []); - is_array($emailSetting) OR $emailSetting = []; + is_array($emailSetting) || $emailSetting = []; $recipients = []; if (in_array($type, $emailSetting)) { diff --git a/app/admin/models/Reviews_model.php b/app/admin/models/Reviews_model.php index f9f3af1ad0..8da661be71 100644 --- a/app/admin/models/Reviews_model.php +++ b/app/admin/models/Reviews_model.php @@ -153,7 +153,7 @@ public function scopeWhereReviewable($query, $causer) public function getSaleTypeModel($saleType) { $model = self::$relatedSaleTypes[$saleType] ?? null; - if (!$model OR !class_exists($model)) + if (!$model || !class_exists($model)) throw new ModelNotFoundException; return new $model(); diff --git a/app/admin/models/Staff_groups_model.php b/app/admin/models/Staff_groups_model.php index a3dc2be3c8..a9d9c97357 100644 --- a/app/admin/models/Staff_groups_model.php +++ b/app/admin/models/Staff_groups_model.php @@ -91,7 +91,7 @@ public function autoAssignEnabled() public function listAssignees() { return $this->staffs->filter(function (Staffs_model $staff) { - return $staff->isEnabled() AND $staff->canAssignTo(); + return $staff->isEnabled() && $staff->canAssignTo(); })->values(); } diff --git a/app/admin/models/Status_history_model.php b/app/admin/models/Status_history_model.php index 0482a6728e..7515e08649 100644 --- a/app/admin/models/Status_history_model.php +++ b/app/admin/models/Status_history_model.php @@ -49,7 +49,7 @@ public static function alreadyExists($model, $statusId) public function getStaffNameAttribute($value) { - return ($this->staff AND $this->staff->exists) ? $this->staff->staff_name : $value; + return ($this->staff && $this->staff->exists) ? $this->staff->staff_name : $value; } public function getDateAddedSinceAttribute($value) @@ -59,7 +59,7 @@ public function getDateAddedSinceAttribute($value) public function getStatusNameAttribute($value) { - return ($this->status AND $this->status->exists) ? $this->status->status_name : $value; + return ($this->status && $this->status->exists) ? $this->status->status_name : $value; } public function getNotifiedAttribute() diff --git a/app/admin/models/Users_model.php b/app/admin/models/Users_model.php index bac72bf90a..31f6fb0c63 100644 --- a/app/admin/models/Users_model.php +++ b/app/admin/models/Users_model.php @@ -148,7 +148,7 @@ public function getPermissions() $role = $this->staff->role; $permissions = []; - if ($role AND is_array($role->permissions)) { + if ($role && is_array($role->permissions)) { $permissions = $role->permissions; } diff --git a/app/admin/models/config/orders_model.php b/app/admin/models/config/orders_model.php index 6f23f46c54..0b36656e2c 100644 --- a/app/admin/models/config/orders_model.php +++ b/app/admin/models/config/orders_model.php @@ -81,7 +81,6 @@ 'location_name' => [ 'label' => 'lang:admin::lang.orders.column_location', 'relation' => 'location', - 'select' => 'location_name', 'searchable' => TRUE, 'locationAware' => TRUE, ], @@ -145,6 +144,11 @@ 'label' => 'lang:admin::lang.orders.column_total', 'type' => 'currency', ], + 'updated_at' => [ + 'label' => 'lang:admin::lang.column_date_updated', + 'type' => 'datesince', + 'invisible' => TRUE, + ], 'created_at' => [ 'label' => 'lang:admin::lang.column_date_added', 'type' => 'timesince', diff --git a/app/admin/models/config/reservations_model.php b/app/admin/models/config/reservations_model.php index eea983d3de..f00878a8fd 100644 --- a/app/admin/models/config/reservations_model.php +++ b/app/admin/models/config/reservations_model.php @@ -74,10 +74,9 @@ 'reservation_id' => [ 'label' => 'lang:admin::lang.column_id', ], - 'location' => [ + 'location_name' => [ 'label' => 'lang:admin::lang.reservations.column_location', 'relation' => 'location', - 'select' => 'location_name', 'searchable' => TRUE, 'locationAware' => TRUE, ], diff --git a/app/admin/requests/Customer.php b/app/admin/requests/Customer.php index dd91686cfb..f9fd847ea2 100644 --- a/app/admin/requests/Customer.php +++ b/app/admin/requests/Customer.php @@ -28,7 +28,7 @@ public function rules() ['addresses.*.country_id', 'admin::lang.customers.label_country', 'required|integer'], ]; - if (!optional($this->getModel())->exists OR $this->inputWith('password')) { + if (!optional($this->getModel())->exists || $this->inputWith('password')) { $rules[] = ['password', 'lang:admin::lang.customers.label_password', 'required_if:send_invite,0|min:8|max:40|same:_confirm_password']; $rules[] = ['_confirm_password', 'lang:admin::lang.customers.label_confirm_password']; } diff --git a/app/admin/traits/Assignable.php b/app/admin/traits/Assignable.php index 02e6aeae71..96a975bdbb 100644 --- a/app/admin/traits/Assignable.php +++ b/app/admin/traits/Assignable.php @@ -34,7 +34,7 @@ protected function performOnAssignableAssigned() { if ( $this->wasChanged('status_id') - AND strlen($this->assignee_group_id) + && strlen($this->assignee_group_id) ) Assignable_logs_model::createLog($this); } diff --git a/app/admin/traits/FormModelWidget.php b/app/admin/traits/FormModelWidget.php index f34353dde5..438f37295e 100644 --- a/app/admin/traits/FormModelWidget.php +++ b/app/admin/traits/FormModelWidget.php @@ -82,7 +82,7 @@ protected function getRelationModel() { [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom); - if (!$model OR !$model->hasRelation($attribute)) { + if (!$model || !$model->hasRelation($attribute)) { throw new ApplicationException(sprintf(lang('admin::lang.alert_missing_model_definition'), get_class($this->model), $this->valueFrom @@ -96,7 +96,7 @@ protected function getRelationObject() { [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom); - if (!$model OR !$model->hasRelation($attribute)) { + if (!$model || !$model->hasRelation($attribute)) { throw new ApplicationException(sprintf(lang('admin::lang.alert_missing_model_definition'), get_class($this->model), $this->valueFrom @@ -132,7 +132,7 @@ protected function prepareModelsToSave($model, $saveData) */ protected function setModelAttributes($model, $saveData) { - if (!is_array($saveData) OR !$model) { + if (!is_array($saveData) || !$model) { return; } @@ -140,12 +140,12 @@ protected function setModelAttributes($model, $saveData) $singularTypes = ['belongsTo', 'hasOne', 'morphTo', 'morphOne']; foreach ($saveData as $attribute => $value) { - $isNested = ($attribute == 'pivot' OR ( - $model->hasRelation($attribute) AND + $isNested = ($attribute == 'pivot' || ( + $model->hasRelation($attribute) && in_array($model->getRelationType($attribute), $singularTypes) )); - if ($isNested AND is_array($value)) { + if ($isNested && is_array($value)) { $this->setModelAttributes($model->{$attribute}, $value); } elseif ($value !== FormField::NO_SAVE_DATA) { diff --git a/app/admin/traits/HasDeliveryAreas.php b/app/admin/traits/HasDeliveryAreas.php index 4ba2180592..47eccdf6c9 100644 --- a/app/admin/traits/HasDeliveryAreas.php +++ b/app/admin/traits/HasDeliveryAreas.php @@ -50,7 +50,7 @@ protected function geocodeAddressOnSave() $address = format_address($this->getAddress(), FALSE); $geoLocation = Geocoder::geocode($address)->first(); - if ($geoLocation AND $geoLocation->hasCoordinates()) { + if ($geoLocation && $geoLocation->hasCoordinates()) { $this->location_lat = $geoLocation->getCoordinates()->getLatitude(); $this->location_lng = $geoLocation->getCoordinates()->getLongitude(); } diff --git a/app/admin/traits/HasInvoice.php b/app/admin/traits/HasInvoice.php index 4897f4ba7b..98502937d9 100644 --- a/app/admin/traits/HasInvoice.php +++ b/app/admin/traits/HasInvoice.php @@ -13,7 +13,7 @@ public static function bootHasInvoice() }); static::saved(function (self $model) { - if ($model->isPaymentProcessed() AND !$model->hasInvoice()) + if ($model->isPaymentProcessed() && !$model->hasInvoice()) $model->generateInvoice(); }); } diff --git a/app/admin/traits/HasWorkingHours.php b/app/admin/traits/HasWorkingHours.php index a242caaea7..5c7a4a8683 100644 --- a/app/admin/traits/HasWorkingHours.php +++ b/app/admin/traits/HasWorkingHours.php @@ -98,7 +98,7 @@ public function getWorkingHours() 'working_hours', )); - if (!$this->working_hours OR $this->working_hours->isEmpty()) { + if (!$this->working_hours || $this->working_hours->isEmpty()) { $this->createDefaultWorkingHours(); } @@ -113,7 +113,7 @@ public function loadWorkingHours() public function newWorkingSchedule($type, $days = null) { $types = $this->availableWorkingTypes(); - if (is_null($type) OR !in_array($type, $types)) + if (is_null($type) || !in_array($type, $types)) throw new InvalidArgumentException(sprintf(lang('admin::lang.locations.alert_invalid_schedule_type'), $type)); if (is_null($days)) { @@ -139,7 +139,7 @@ public function newWorkingSchedule($type, $days = null) public function createScheduleItem($type) { - if (is_null($type) OR !in_array($type, $this->availableWorkingTypes())) + if (is_null($type) || !in_array($type, $this->availableWorkingTypes())) throw new InvalidArgumentException(sprintf(lang('admin::lang.locations.alert_invalid_schedule_type'), $type)); $scheduleData = array_get($this->getOption('hours', []), $type, []); @@ -225,7 +225,7 @@ protected function parseHoursFromOptions(&$value) } } - if (isset($hours['flexible_hours']) AND is_array($hours['flexible_hours'])) { + if (isset($hours['flexible_hours']) && is_array($hours['flexible_hours'])) { foreach (['opening', 'delivery', 'collection'] as $type) { $value['hours'][$type]['flexible'] = $hours['flexible_hours']; } diff --git a/app/admin/traits/LocationAwareWidget.php b/app/admin/traits/LocationAwareWidget.php index 6156d5c69d..c10d29cd08 100644 --- a/app/admin/traits/LocationAwareWidget.php +++ b/app/admin/traits/LocationAwareWidget.php @@ -11,7 +11,7 @@ protected function isLocationAware($config) { $locationAware = $config['locationAware'] ?? FALSE; - return $locationAware AND $this->controller->getUserLocation(); + return $locationAware && $this->controller->getUserLocation(); } /** diff --git a/app/admin/traits/Locationable.php b/app/admin/traits/Locationable.php index 97a1196c90..fc66430cfa 100644 --- a/app/admin/traits/Locationable.php +++ b/app/admin/traits/Locationable.php @@ -100,7 +100,7 @@ protected function detachLocationsOnDelete() $locationable = $this->getLocationableRelationObject(); - if (app()->runningInAdmin() AND !AdminAuth::isSuperUser() AND $locationable->count() > 1) { + if (app()->runningInAdmin() && !AdminAuth::isSuperUser() && $locationable->count() > 1) { throw new ApplicationException(lang('admin::lang.alert_warning_locationable_delete')); } diff --git a/app/admin/traits/LogsStatusHistory.php b/app/admin/traits/LogsStatusHistory.php index 093fc4cbc6..425cc8512f 100644 --- a/app/admin/traits/LogsStatusHistory.php +++ b/app/admin/traits/LogsStatusHistory.php @@ -43,7 +43,7 @@ public function getLatestStatusHistory() public function addStatusHistory($status, array $statusData = []) { - if (!$this->exists OR !$status) + if (!$this->exists || !$status) return FALSE; $this->status()->associate($status); diff --git a/app/admin/traits/ManagesOrderItems.php b/app/admin/traits/ManagesOrderItems.php index 04097c1eb2..0d3c56ef74 100644 --- a/app/admin/traits/ManagesOrderItems.php +++ b/app/admin/traits/ManagesOrderItems.php @@ -141,7 +141,7 @@ public function addOrderMenus(array $content) 'option_values' => serialize($cartItem->options), ]); - if ($orderMenuId AND count($cartItem->options)) { + if ($orderMenuId && count($cartItem->options)) { $this->addOrderMenuOptions($orderMenuId, $cartItem->id, $cartItem->options); } } diff --git a/app/admin/traits/WidgetMaker.php b/app/admin/traits/WidgetMaker.php index 0f7c08534d..038f63982a 100644 --- a/app/admin/traits/WidgetMaker.php +++ b/app/admin/traits/WidgetMaker.php @@ -46,7 +46,7 @@ public function makeWidget($class, $widgetConfig = []) */ public function makeFormWidget($class, $fieldConfig = [], $widgetConfig = []) { - $controller = (property_exists($this, 'controller') AND $this->controller) + $controller = (property_exists($this, 'controller') && $this->controller) ? $this->controller : $this; diff --git a/app/admin/views/_partials/form/toolbar_save_button.blade.php b/app/admin/views/_partials/form/toolbar_save_button.blade.php index daaf7c6e43..1948a4da86 100644 --- a/app/admin/views/_partials/form/toolbar_save_button.blade.php +++ b/app/admin/views/_partials/form/toolbar_save_button.blade.php @@ -1,7 +1,7 @@ @php $saveActions = array_get($button->config, 'saveActions', ['continue', 'close', 'new']); $selectedAction = @json_decode($d = array_get($_COOKIE, 'ti_activeFormSaveAction'), TRUE); - $selectedAction = ($selectedAction AND in_array($selectedAction, $saveActions)) ? $selectedAction : 'continue'; + $selectedAction = ($selectedAction && in_array($selectedAction, $saveActions)) ? $selectedAction : 'continue'; @endphp
@foreach (['continue', 'close', 'new'] as $action) - @continue($saveActions AND !in_array($action, $saveActions)) + @continue($saveActions && !in_array($action, $saveActions)) - @if(!$hasSettingsError AND $updatesCount) + @if(!$hasSettingsError && $updatesCount) @foreach($model->getOrderTotals() as $total) - @continue($model->isCollectionType() AND $total->code == 'delivery') - @php $thickLine = ($total->code == 'order_total' OR $total->code == 'total') @endphp + @continue($model->isCollectionType() && $total->code == 'delivery') + @php $thickLine = ($total->code == 'order_total' || $total->code == 'total') @endphp {{ $total->title }} {{ currency_format($total->value) }} @endforeach diff --git a/app/admin/views/orders/invoice.blade.php b/app/admin/views/orders/invoice.blade.php index a026e64eb3..c6aa3f51b1 100644 --- a/app/admin/views/orders/invoice.blade.php +++ b/app/admin/views/orders/invoice.blade.php @@ -135,13 +135,13 @@ @foreach($model->getOrderTotals() as $total) - @continue($model->isCollectionType() AND $total->code == 'delivery') - @php $thickLine = ($total->code == 'order_total' OR $total->code == 'total') @endphp + @continue($model->isCollectionType() && $total->code == 'delivery') + @php $thickLine = ($total->code == 'order_total' || $total->code == 'total') @endphp - - - {{ $total->title }} - {{ currency_format($total->value) }} + + + {{ $total->title }} + {{ currency_format($total->value) }} @endforeach diff --git a/app/admin/widgets/Filter.php b/app/admin/widgets/Filter.php index 2535610cf9..28c17d4cc2 100644 --- a/app/admin/widgets/Filter.php +++ b/app/admin/widgets/Filter.php @@ -174,7 +174,7 @@ public function onSubmit() case 'daterange': $format = array_get($scope->config, 'showTimePicker', FALSE) ? 'Y-m-d H:i:s' : 'Y-m-d'; - $dateRange = (is_array($value) AND count($value) === 2 AND $value[0] != '') ? [ + $dateRange = (is_array($value) && count($value) === 2 && $value[0] != '') ? [ make_carbon($value[0])->format($format), make_carbon($value[1])->format($format), ] : NULL; @@ -313,7 +313,7 @@ protected function defineFilterScopes() $this->fireSystemEvent('admin.filter.extendScopesBefore'); - if (!isset($this->scopes) OR !is_array($this->scopes)) { + if (!isset($this->scopes) || !is_array($this->scopes)) { $this->scopes = []; } @@ -336,7 +336,7 @@ public function addScopes(array $scopes) // Check if admin has permissions to show this column $permissions = array_get($config, 'permissions'); - if (!empty($permissions) AND !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { + if (!empty($permissions) && !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { continue; } @@ -426,7 +426,7 @@ public function applyScopeToQuery($scope, $query) $scope = $this->getScope($scope); } - if ($scope->disabled OR ($scope->value !== '0' AND !$scope->value)) { + if ($scope->disabled || ($scope->value !== '0' && !$scope->value)) { return; } diff --git a/app/admin/widgets/Form.php b/app/admin/widgets/Form.php index c3611f9b6d..33b3feb163 100644 --- a/app/admin/widgets/Form.php +++ b/app/admin/widgets/Form.php @@ -369,7 +369,7 @@ public function addFields(array $fields, $addToArea = null) foreach ($fields as $name => $config) { // Check if admin has permissions to show this field $permissions = array_get($config, 'permissions'); - if (!empty($permissions) AND !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { + if (!empty($permissions) && !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { continue; } @@ -476,7 +476,7 @@ public function makeFormField($name, $config) } // Defined field type else { $fieldType = $config['type'] ?? null; - if (!is_string($fieldType) AND !is_null($fieldType)) { + if (!is_string($fieldType) && !is_null($fieldType)) { throw new Exception(sprintf( lang('admin::lang.form.field_invalid_type'), gettype($fieldType) )); @@ -742,14 +742,14 @@ public function getSaveData() // Spin over each field and extract the postback value foreach ($this->allFields as $field) { // Disabled and hidden should be omitted from data set - if ($field->disabled OR $field->hidden OR starts_with($field->fieldName, '_')) { + if ($field->disabled || $field->hidden || starts_with($field->fieldName, '_')) { continue; } // Handle HTML array, eg: item[key][another] $parts = name_to_array($field->fieldName); $value = $this->dataArrayGet($data, $parts); - if (is_null($value) AND in_array($field->type, ['checkboxtoggle', 'radiotoggle'])) { + if (is_null($value) && in_array($field->type, ['checkboxtoggle', 'radiotoggle'])) { $this->dataArraySet($result, $parts, $value); } elseif ($value !== null) { @@ -766,7 +766,7 @@ public function getSaveData() foreach ($this->formWidgets as $field => $widget) { $parts = name_to_array($field); - if (isset($widget->config->disabled) AND $widget->config->disabled) + if (isset($widget->config->disabled) && $widget->config->disabled) continue; $widgetValue = $widget->getSaveValue($this->dataArrayGet($result, $parts)); @@ -864,7 +864,7 @@ protected function defineFormFields() $this->fireSystemEvent('admin.form.extendFieldsBefore'); // Outside fields - if (!isset($this->fields) OR !is_array($this->fields)) { + if (!isset($this->fields) || !is_array($this->fields)) { $this->fields = []; } @@ -872,7 +872,7 @@ protected function defineFormFields() $this->addFields($this->fields); // Primary Tabs + Fields - if (!isset($this->tabs['fields']) OR !is_array($this->tabs['fields'])) { + if (!isset($this->tabs['fields']) || !is_array($this->tabs['fields'])) { $this->tabs['fields'] = []; } @@ -900,7 +900,7 @@ protected function defineFormFields() // At least one tab section should stretch if ( $this->allTabs->primary->stretch === null - AND $this->allTabs->outside->stretch === null + && $this->allTabs->outside->stretch === null ) { if ($this->allTabs->primary->hasFields()) { $this->allTabs->primary->stretch = TRUE; @@ -1001,17 +1001,17 @@ protected function applyFiltersFromModel() protected function getOptionsFromModel($field, $fieldOptions) { // Advanced usage, supplied options are callable - if (is_array($fieldOptions) AND is_callable($fieldOptions)) { + if (is_array($fieldOptions) && is_callable($fieldOptions)) { $fieldOptions = $fieldOptions($this, $field); } // Refer to the model method or any of its behaviors - if (!is_array($fieldOptions) AND !$fieldOptions) { + if (!is_array($fieldOptions) && !$fieldOptions) { [$model, $attribute] = $field->resolveModelAttribute($this->model, $field->fieldName); $methodName = 'get'.studly_case($attribute).'Options'; if ( - !$this->objectMethodExists($model, $methodName) AND + !$this->objectMethodExists($model, $methodName) && !$this->objectMethodExists($model, 'getDropdownOptions') ) { throw new Exception(sprintf(lang('admin::lang.form.options_method_not_exists'), @@ -1078,7 +1078,7 @@ protected function dataArrayGet(array $array, array $parts, $default = null) } foreach ($parts as $segment) { - if (!is_array($array) OR !array_key_exists($segment, $array)) { + if (!is_array($array) || !array_key_exists($segment, $array)) { return $default; } @@ -1106,7 +1106,7 @@ protected function dataArraySet(array &$array, array $parts, $value) while (count($parts) > 1) { $key = array_shift($parts); - if (!isset($array[$key]) OR !is_array($array[$key])) { + if (!isset($array[$key]) || !is_array($array[$key])) { $array[$key] = []; } diff --git a/app/admin/widgets/Lists.php b/app/admin/widgets/Lists.php index aed10c9bf1..c1f1357be0 100644 --- a/app/admin/widgets/Lists.php +++ b/app/admin/widgets/Lists.php @@ -175,7 +175,7 @@ public function initialize() ); if ($this->showPagination == 'auto') { - $this->showPagination = $this->pageLimit AND $this->pageLimit > 0; + $this->showPagination = $this->pageLimit && $this->pageLimit > 0; } $this->validateModel(); @@ -236,7 +236,7 @@ public function onPaginate() protected function validateModel() { - if (!$this->model OR !$this->model instanceof \Illuminate\Database\Eloquent\Model) { + if (!$this->model || !$this->model instanceof \Illuminate\Database\Eloquent\Model) { throw new Exception(sprintf(lang('admin::lang.list.missing_model'), get_class($this->controller))); } @@ -274,7 +274,7 @@ public function prepareModel() $primarySearchable = []; $relationSearchable = []; - if (!empty($this->searchTerm) AND ($searchableColumns = $this->getSearchableColumns())) { + if (!empty($this->searchTerm) && ($searchableColumns = $this->getSearchableColumns())) { foreach ($searchableColumns as $column) { // Relation if ($this->isColumnRelated($column)) { @@ -297,7 +297,7 @@ public function prepareModel() // Prepare related eager loads (withs) and custom selects (joins) foreach ($this->getVisibleColumns() as $column) { - if (!$this->isColumnRelated($column) OR (!isset($column->sqlSelect) AND !isset($column->valueFrom))) + if (!$this->isColumnRelated($column) || (!isset($column->sqlSelect) && !isset($column->valueFrom))) continue; $withs[] = $column->relation; @@ -369,7 +369,7 @@ public function prepareModel() // Apply sorting if ($sortColumn = $this->getSortColumn()) { - if (($column = array_get($this->allColumns, $sortColumn)) AND $column->valueFrom) { + if (($column = array_get($this->allColumns, $sortColumn)) && $column->valueFrom) { $sortColumn = $column->valueFrom; } @@ -476,7 +476,7 @@ public function getVisibleColumns() */ protected function defineListColumns() { - if (!isset($this->columns) OR !is_array($this->columns) OR !count($this->columns)) { + if (!isset($this->columns) || !is_array($this->columns) || !count($this->columns)) { throw new Exception(sprintf(lang('admin::lang.list.missing_column'), get_class($this->controller))); } @@ -522,7 +522,7 @@ public function addColumns(array $columns) foreach ($columns as $columnName => $config) { // Check if admin has permissions to show this column $permissions = array_get($config, 'permissions'); - if (!empty($permissions) AND !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { + if (!empty($permissions) && !AdminAuth::getUser()->hasPermission($permissions, FALSE)) { continue; } @@ -560,13 +560,13 @@ public function makeListColumn($name, $config) $label = studly_case($name); } - if (starts_with($name, 'pivot[') AND strpos($name, ']') !== FALSE) { + if (starts_with($name, 'pivot[') && strpos($name, ']') !== FALSE) { $_name = name_to_array($name); $config['relation'] = array_shift($_name); $config['valueFrom'] = array_shift($_name); $config['searchable'] = FALSE; } - elseif (strpos($name, '[') !== FALSE AND strpos($name, ']') !== FALSE) { + elseif (strpos($name, '[') !== FALSE && strpos($name, ']') !== FALSE) { $config['valueFrom'] = $name; $config['sortable'] = FALSE; $config['searchable'] = FALSE; @@ -653,7 +653,7 @@ public function getColumnValue($record, $column) } // Apply default value. - if ($value === '' OR $value === null) + if ($value === '' || $value === null) $value = $column->defaults; // Extensibility @@ -661,7 +661,7 @@ public function getColumnValue($record, $column) $value = $response; } - if (is_callable($column->formatter) AND ($response = call_user_func_array($column->formatter, [$record, $column, $value])) !== null) { + if (is_callable($column->formatter) && ($response = call_user_func_array($column->formatter, [$record, $column, $value])) !== null) { $value = $response; } @@ -686,7 +686,7 @@ public function getButtonAttributes($record, $column) $result['class'] = isset($result['class']) ? $result['class'] : null; foreach ($result as $key => $value) { - if ($key == 'href' AND !preg_match('#^(\w+:)?//#i', $value)) { + if ($key == 'href' && !preg_match('#^(\w+:)?//#i', $value)) { $result[$key] = $this->controller->pageUrl($value); } elseif (is_string($value)) { @@ -694,6 +694,11 @@ public function getButtonAttributes($record, $column) } } + if (isset($result['url'])) { + $result['href'] = $result['url']; + unset($result['url']); + } + $data = $record->getOriginal(); $data += [$record->getKeyName() => $record->getKey()]; @@ -711,7 +716,7 @@ public function getValueFromData($record, $column, $columnName) elseif ($this->isColumnRelated($column, TRUE)) { $value = implode(', ', $record->{$columnName}->pluck($column->valueFrom)->all()); } - elseif ($this->isColumnRelated($column) OR $this->isColumnPivot($column)) { + elseif ($this->isColumnRelated($column) || $this->isColumnPivot($column)) { $value = $record->{$columnName} ? $record->{$columnName}->{$column->valueFrom} : null; } else { @@ -791,10 +796,10 @@ protected function evalDatetimeTypeValue($record, $column, $value) $dateTime = $this->validateDateTimeValue($value, $column); - $format = $column->format ?? lang('system::lang.php.date_time_format'); + $format = $column->format ?? lang('system::lang.moment.date_time_format'); $format = parse_date_format($format); - return $dateTime->format($format); + return $dateTime->isoFormat($format); } /** @@ -808,10 +813,10 @@ protected function evalTimeTypeValue($record, $column, $value) $dateTime = $this->validateDateTimeValue($value, $column); - $format = $column->format ?? lang('system::lang.php.time_format'); + $format = $column->format ?? lang('system::lang.moment.time_format'); $format = parse_date_format($format); - return $dateTime->format($format); + return $dateTime->isoFormat($format); } /** @@ -825,12 +830,10 @@ protected function evalDateTypeValue($record, $column, $value) $dateTime = $this->validateDateTimeValue($value, $column); - $format = $column->format ?? lang('system::lang.php.date_format'); + $format = $column->format ?? lang('system::lang.moment.date_format'); $format = parse_date_format($format); - return $format - ? $dateTime->format($format) - : $dateTime->toDayDateTimeString($format); + return $dateTime->isoFormat($format); } /** @@ -990,7 +993,7 @@ public function onSort() // Toggle the sort direction and set the sorting column $sortOptions = [$this->getSortColumn(), $this->sortDirection]; - if ($column != $sortOptions[0] OR strtolower($sortOptions[1]) == 'asc') { + if ($column != $sortOptions[0] || strtolower($sortOptions[1]) == 'asc') { $this->sortDirection = $sortOptions[1] = 'desc'; } else { @@ -1020,7 +1023,7 @@ protected function getSortColumn() return $this->sortColumn; // User preference - if ($this->showSorting AND ($sortOptions = $this->getSession('sort'))) { + if ($this->showSorting && ($sortOptions = $this->getSession('sort'))) { $this->sortColumn = $sortOptions[0]; $this->sortDirection = $sortOptions[1]; } // Supplied default @@ -1029,17 +1032,17 @@ protected function getSortColumn() $this->sortColumn = $this->defaultSort; $this->sortDirection = 'desc'; } - elseif (is_array($this->defaultSort) AND isset($this->defaultSort[0])) { + elseif (is_array($this->defaultSort) && isset($this->defaultSort[0])) { $this->sortColumn = $this->defaultSort[0]; $this->sortDirection = (isset($this->defaultSort[1])) ? $this->defaultSort[1] : 'desc'; } } // First available column - if ($this->sortColumn === null OR !$this->isSortable($this->sortColumn)) { + if ($this->sortColumn === null || !$this->isSortable($this->sortColumn)) { $columns = $this->visibleColumns ?: $this->getVisibleColumns(); $columns = array_filter($columns, function ($column) { - return $column->sortable AND $column->type != 'button'; + return $column->sortable && $column->type != 'button'; }); $this->sortColumn = key($columns); $this->sortDirection = 'desc'; @@ -1105,7 +1108,7 @@ public function onLoadSetup() */ public function onApplySetup() { - if (($visibleColumns = post('visible_columns')) AND is_array($visibleColumns)) { + if (($visibleColumns = post('visible_columns')) && is_array($visibleColumns)) { $this->columnOverride = $visibleColumns; $this->putSession('visible', $this->columnOverride); } @@ -1170,7 +1173,7 @@ public function onBulkAction() throw new ApplicationException(sprintf(lang('admin::lang.list.action_not_found'), $actionCode)); $checkedIds = array_get($requestData, 'checked'); - if (!$checkedIds OR !is_array($checkedIds) OR !count($checkedIds)) + if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) throw new ApplicationException(lang('admin::lang.list.delete_empty')); $alias = post('alias') ?: $this->primaryAlias; @@ -1223,7 +1226,7 @@ protected function makeBulkActionButtons($bulkActions, $parentActionCode = null) // Check if admin has permissions to show this column $permissions = array_get($config, 'permissions'); - if (!empty($permissions) AND !AdminAuth::getUser()->hasPermission($permissions, FALSE)) + if (!empty($permissions) && !AdminAuth::getUser()->hasPermission($permissions, FALSE)) continue; // Check that the filter scope matches the active location context @@ -1244,7 +1247,7 @@ protected function makeBulkActionButton($actionCode, $config) $buttonObj = new ToolbarButton($actionCode); $buttonObj->displayAs($buttonType, $config); - if ($buttonType === 'dropdown' AND array_key_exists('menuItems', $config)) { + if ($buttonType === 'dropdown' && array_key_exists('menuItems', $config)) { $buttonObj->menuItems($this->makeBulkActionButtons($config['menuItems'], $actionCode)); } @@ -1285,7 +1288,7 @@ protected function makeBulkActionWidget($actionButton) */ protected function isColumnRelated($column, $multi = FALSE) { - if (!isset($column->relation) OR $this->isColumnPivot($column)) { + if (!isset($column->relation) || $this->isColumnPivot($column)) { return FALSE; } @@ -1319,6 +1322,6 @@ protected function isColumnRelated($column, $multi = FALSE) */ protected function isColumnPivot($column) { - return isset($column->relation) AND $column->relation == 'pivot'; + return isset($column->relation) && $column->relation == 'pivot'; } } diff --git a/app/admin/widgets/Menu.php b/app/admin/widgets/Menu.php index 818df0f6c4..a5ff476d5f 100644 --- a/app/admin/widgets/Menu.php +++ b/app/admin/widgets/Menu.php @@ -89,7 +89,7 @@ protected function defineMenuItems() if ($this->itemsDefined) return; - if (!isset($this->items) OR !is_array($this->items)) { + if (!isset($this->items) || !is_array($this->items)) { $this->items = []; } @@ -253,7 +253,7 @@ public function onChooseLocation() if (is_numeric($locationId = post('location'))) $location = Locations_model::find($locationId); - if ($location AND AdminLocation::hasAccess($location)) { + if ($location && AdminLocation::hasAccess($location)) { AdminLocation::setCurrent($location); } else { @@ -269,7 +269,7 @@ public function onSetUserStatus() $message = (string)post('message'); $clearAfterMinutes = (int)post('clear_after'); - if ($status < 1 AND !strlen($message)) + if ($status < 1 && !strlen($message)) throw new ApplicationException(lang('admin::lang.side_menu.alert_invalid_status')); $stateData['status'] = $status; @@ -292,7 +292,7 @@ public function getContext() protected function getOptionsFromModel($item, $itemOptions) { - if (is_array($itemOptions) AND is_callable($itemOptions)) { + if (is_array($itemOptions) && is_callable($itemOptions)) { $user = $this->getLoggedUser(); $itemOptions = call_user_func($itemOptions, $this, $item, $user); } @@ -302,7 +302,7 @@ protected function getOptionsFromModel($item, $itemOptions) protected function getUnreadCountFromModel($item, $itemBadgeCount) { - if (is_array($itemBadgeCount) AND is_callable($itemBadgeCount)) { + if (is_array($itemBadgeCount) && is_callable($itemBadgeCount)) { $user = $this->getLoggedUser(); $itemBadgeCount = $itemBadgeCount($this, $item, $user); } @@ -313,7 +313,7 @@ protected function getUnreadCountFromModel($item, $itemBadgeCount) protected function resolveMarkAsReadFromModel($item) { $callback = array_get($item->config, 'markAsRead'); - if (is_array($callback) AND is_callable($callback)) { + if (is_array($callback) && is_callable($callback)) { $user = $this->getLoggedUser(); $callback($this, $item, $user); } diff --git a/app/admin/widgets/Table.php b/app/admin/widgets/Table.php index 424d183bbf..b484d297f2 100644 --- a/app/admin/widgets/Table.php +++ b/app/admin/widgets/Table.php @@ -67,7 +67,7 @@ public function initialize() $this->dataSource = new $dataSourceClass($this->recordsKeyFrom); - if (Request::method() == 'post' AND $this->isClientDataSource()) { + if (Request::method() == 'post' && $this->isClientDataSource()) { if (strpos($this->fieldName, '[') === FALSE) { $requestDataField = $this->fieldName.'TableData'; } diff --git a/app/admin/widgets/Toolbar.php b/app/admin/widgets/Toolbar.php index d7ff6818bf..680f81a45a 100644 --- a/app/admin/widgets/Toolbar.php +++ b/app/admin/widgets/Toolbar.php @@ -150,7 +150,7 @@ protected function makeButtons($buttons) $result = []; foreach ($buttons as $name => $attributes) { $permission = array_get($attributes, 'permission'); - if ($permission AND !AdminAuth::user()->hasPermission($permission)) { + if ($permission && !AdminAuth::user()->hasPermission($permission)) { continue; } @@ -182,7 +182,7 @@ protected function makeButton(string $name, array $config) $buttonObj = new ToolbarButton($name); $buttonObj->displayAs($buttonType, $config); - if ($buttonType === 'dropdown' AND array_key_exists('menuItems', $config)) { + if ($buttonType === 'dropdown' && array_key_exists('menuItems', $config)) { $buttonObj->menuItems($this->makeButtons($config['menuItems'])); } diff --git a/app/admin/widgets/form/field.blade.php b/app/admin/widgets/form/field.blade.php index e5d99378ef..f25b413864 100644 --- a/app/admin/widgets/form/field.blade.php +++ b/app/admin/widgets/form/field.blade.php @@ -6,7 +6,7 @@ @endif - @if ($field->comment AND $field->commentPosition == 'above') + @if ($field->comment && $field->commentPosition == 'above')

@if ($field->commentHtml) {!! lang($field->comment) !!} @else @lang($field->comment) @endif

@@ -14,7 +14,7 @@ {!! $this->renderFieldElement($field) !!} - @if ($field->comment AND $field->commentPosition == 'below') + @if ($field->comment && $field->commentPosition == 'below')

@if ($field->commentHtml) {!! lang($field->comment) !!} @else @lang($field->comment) @endif

diff --git a/app/admin/widgets/form/field_checkboxlist.blade.php b/app/admin/widgets/form/field_checkboxlist.blade.php index 940d9d99ce..e3a4d91200 100644 --- a/app/admin/widgets/form/field_checkboxlist.blade.php +++ b/app/admin/widgets/form/field_checkboxlist.blade.php @@ -33,7 +33,7 @@ class="custom-control-input" @endforeach
-@elseif (!$this->previewMode AND count($fieldOptions)) +@elseif (!$this->previewMode && count($fieldOptions))
@if ($isScrollable) @@ -64,7 +64,7 @@ class="custom-control-input" class="custom-control-input" name="{{ $field->getName() }}[]" value="{{ $value }}" - {!! in_array($value, $checkedValues) ? 'checked="checked"' : '' !!}> + {!! in_array($value, $checkedValues) ? 'checked="checked"' : '' !!}>
- @if ($this->previewMode AND $field->value) + @if ($this->previewMode && $field->value)
getId() }}" class="btn-group btn-group-toggle bg-light" diff --git a/app/admin/widgets/form/field_radiolist.blade.php b/app/admin/widgets/form/field_radiolist.blade.php index c19eb07799..3b9c8b79ba 100644 --- a/app/admin/widgets/form/field_radiolist.blade.php +++ b/app/admin/widgets/form/field_radiolist.blade.php @@ -33,7 +33,7 @@ class="custom-control-input" @endforeach
-@elseif (!$this->previewMode AND count($fieldOptions)) +@elseif (!$this->previewMode && count($fieldOptions))
@if ($isScrollable) diff --git a/app/admin/widgets/form/field_selectlist.blade.php b/app/admin/widgets/form/field_selectlist.blade.php index 1b7e35d2ca..73d070238e 100644 --- a/app/admin/widgets/form/field_selectlist.blade.php +++ b/app/admin/widgets/form/field_selectlist.blade.php @@ -23,7 +23,7 @@ @endif @foreach ($fieldOptions as $value => $option) - @continue($field->disabled AND !in_array($value, $checkedValues)) + @continue($field->disabled && !in_array($value, $checkedValues)) @php if (!is_array($option)) $option = [$option]; @endphp diff --git a/app/admin/widgets/lists/list_head.blade.php b/app/admin/widgets/lists/list_head.blade.php index 1e4475e634..849805f7ac 100644 --- a/app/admin/widgets/lists/list_head.blade.php +++ b/app/admin/widgets/lists/list_head.blade.php @@ -19,7 +19,7 @@ class="custom-control-input" onclick="$('input[name*=\'checked\']').prop('checke @foreach ($columns as $key => $column) @if ($column->type == 'button') - @elseif ($showSorting AND $column->sortable) + @elseif ($showSorting && $column->sortable) width) style="width: {{ $column->width }}" @endif> diff --git a/app/admin/widgets/menu/item_dropdown.blade.php b/app/admin/widgets/menu/item_dropdown.blade.php index af9bb4b51f..06b300c10a 100644 --- a/app/admin/widgets/menu/item_dropdown.blade.php +++ b/app/admin/widgets/menu/item_dropdown.blade.php @@ -1,6 +1,6 @@ @php -$itemOptions = (isset($hasPartial) AND $hasPartial) ? [] : $item->options(); -is_array($itemOptions) OR $itemOptions = []; + $itemOptions = (isset($hasPartial) && $hasPartial) ? [] : $item->options(); + is_array($itemOptions) || $itemOptions = []; @endphp
  • getPathsCacheKey(); // Remove any existing cache data - if ($refresh AND $this->allowCacheRefreshes) + if ($refresh && $this->allowCacheRefreshes) Cache::forget($cacheKey); // Load the cache @@ -202,7 +202,7 @@ public function update($dirName, $fileName, $extension, $content, $oldFileName = // Ensure that files that are being renamed have their old names marked as deleted prior to inserting the renamed file // Also ensure that the cache only gets updated at the end of this operation instead of twice, once here and again at the end - if ($searchFileName !== $fileName OR $searchExt !== $extension) { + if ($searchFileName !== $fileName || $searchExt !== $extension) { $this->allowCacheRefreshes = FALSE; $this->delete($dirName, $searchFileName, $searchExt); $this->allowCacheRefreshes = TRUE; diff --git a/app/main/classes/MainController.php b/app/main/classes/MainController.php index c1347dc243..e438f24d90 100644 --- a/app/main/classes/MainController.php +++ b/app/main/classes/MainController.php @@ -177,7 +177,7 @@ public function remap($url = null) $page = $this->router->findByUrl($url); // Show maintenance message if maintenance is enabled - if (setting('maintenance_mode') == 1 AND !AdminAuth::isLogged()) + if (setting('maintenance_mode') == 1 && !AdminAuth::isLogged()) return Response::make( View::make('main::maintenance', ['message' => setting('maintenance_message')]), $this->statusCode @@ -185,7 +185,7 @@ public function remap($url = null) // If the page was not found, // render the 404 page - either provided by the theme or the built-in one. - if (!$page OR $url === '404') { + if (!$page || $url === '404') { if (!Request::ajax()) $this->setStatusCode(404); @@ -257,7 +257,7 @@ public function runPage($page) } // Execute post handler and AJAX event - if ($ajaxResponse = $this->processHandlers() AND $ajaxResponse !== TRUE) { + if (($ajaxResponse = $this->processHandlers()) && $ajaxResponse !== TRUE) { return $ajaxResponse; } @@ -301,7 +301,7 @@ protected function execPageCycle() if ($this->layoutObj) { // Let the layout do stuff after components are initialized and before AJAX is handled. $response = ( - ($result = $this->layoutObj->onStart()) OR + ($result = $this->layoutObj->onStart()) || ($result = $this->layout->runComponents()) ) ? $result : null; @@ -312,8 +312,8 @@ protected function execPageCycle() // Run page functions $response = ( - ($result = $this->pageObj->onStart()) OR - ($result = $this->page->runComponents()) OR + ($result = $this->pageObj->onStart()) || + ($result = $this->page->runComponents()) || ($result = $this->pageObj->onEnd()) ) ? $result : null; @@ -344,7 +344,7 @@ protected function execPageCycle() */ public function getHandler() { - if (Request::ajax() AND $handler = Request::header('X-IGNITER-REQUEST-HANDLER')) + if (Request::ajax() && $handler = Request::header('X-IGNITER-REQUEST-HANDLER')) return trim($handler); if ($handler = post('_handler')) @@ -381,7 +381,7 @@ protected function processHandlers() $response['X_IGNITER_REDIRECT'] = $result->getTargetUrl(); $result = null; } - elseif (Request::header('X-IGNITER-REQUEST-FLASH') AND Flash::messages()->isNotEmpty()) { + elseif (Request::header('X-IGNITER-REQUEST-FLASH') && Flash::messages()->isNotEmpty()) { $response['X_IGNITER_FLASH_MESSAGES'] = Flash::all(); } @@ -414,7 +414,7 @@ protected function runHandler($handler) $componentObj = $this->findComponentByAlias($componentName); - if ($componentObj AND $componentObj->methodExists($handlerName)) { + if ($componentObj && $componentObj->methodExists($handlerName)) { $this->componentContext = $componentObj; $result = $componentObj->runEventHandler($handlerName); @@ -424,7 +424,7 @@ protected function runHandler($handler) else { $pageHandler = $this->action.'_'.$handler; if ($this->methodExists($pageHandler)) { - $result = call_user_func_array([$this, $pageHandler], $this->params); + $result = call_user_func_array([$this, $pageHandler], array_values($this->params)); return $result ?: TRUE; } diff --git a/app/main/classes/MediaLibrary.php b/app/main/classes/MediaLibrary.php index 5f47218d1a..de55ae465b 100644 --- a/app/main/classes/MediaLibrary.php +++ b/app/main/classes/MediaLibrary.php @@ -111,7 +111,7 @@ public function listFolders($path = null, array $exclude = [], $recursive = FALS $result[] = $folder; } - if ($path == '/' AND !in_array('/', $result)) + if ($path == '/' && !in_array('/', $result)) array_unshift($result, '/'); return $result; diff --git a/app/main/classes/Router.php b/app/main/classes/Router.php index c7c9a5a0f5..52d0db58c2 100644 --- a/app/main/classes/Router.php +++ b/app/main/classes/Router.php @@ -106,7 +106,7 @@ public function findByUrl($url) $fileName = $router->matchedRoute(); if ($cacheable) { - if (!$urlList OR !is_array($urlList)) + if (!$urlList || !is_array($urlList)) $urlList = []; $urlList[$url] = !empty($this->parameters) @@ -207,7 +207,7 @@ protected function loadUrlMap() $cacheable = Config::get('system.enableRoutesCache'); $cached = $cacheable ? Cache::get($this->getUrlMapCacheKey(), FALSE) : FALSE; - if (!$cached OR ($unSerialized = @unserialize(@base64_decode($cached))) === FALSE) { + if (!$cached || ($unSerialized = @unserialize(@base64_decode($cached))) === FALSE) { // The item doesn't exist in the cache, create the map $pages = $this->theme->listPages(); $map = []; @@ -284,7 +284,7 @@ public function getUrl() */ public function getParameter($name, $default = null) { - if (isset($this->parameters[$name]) AND !empty($this->parameters[$name])) { + if (isset($this->parameters[$name]) && !empty($this->parameters[$name])) { return $this->parameters[$name]; } @@ -335,8 +335,8 @@ protected function getCachedUrlFileName($url, &$urlList) $urlList = Cache::get($key, FALSE); if ( - $urlList AND - ($urlList = @unserialize(@base64_decode($urlList))) AND + $urlList && + ($urlList = @unserialize(@base64_decode($urlList))) && is_array($urlList) ) { if (array_key_exists($url, $urlList)) { diff --git a/app/main/classes/ThemeManager.php b/app/main/classes/ThemeManager.php index aa956a1623..f2feace1af 100644 --- a/app/main/classes/ThemeManager.php +++ b/app/main/classes/ThemeManager.php @@ -78,7 +78,7 @@ public static function applyAssetVariablesOnCombinerFilters(array $filters, Them { $theme = !is_null($theme) ? $theme : self::instance()->getActiveTheme(); - if (!$theme OR !$theme->hasCustomData()) + if (!$theme || !$theme->hasCustomData()) return; $assetVars = $theme->getAssetVariables(); @@ -112,7 +112,7 @@ public function listThemes() */ public function loadInstalled() { - if (($installedThemes = setting('installed_themes')) AND is_array($installedThemes)) { + if (($installedThemes = setting('installed_themes')) && is_array($installedThemes)) { $this->installedThemes = $installedThemes; } } @@ -289,7 +289,7 @@ public function isDisabled($name) { traceLog('Deprecated. Use $instance::isActive($themeCode) instead'); - return !$this->checkName($name) OR !array_get($this->installedThemes, $name, FALSE); + return !$this->checkName($name) || !array_get($this->installedThemes, $name, FALSE); } /** @@ -304,7 +304,7 @@ public function checkName($themeCode) if ($themeCode == 'errors') return null; - return (strpos($themeCode, '_') === 0 OR preg_match('/\s/', $themeCode)) ? null : $themeCode; + return (strpos($themeCode, '_') === 0 || preg_match('/\s/', $themeCode)) ? null : $themeCode; } /** @@ -341,7 +341,7 @@ public function isLocked($themeCode) public function checkParent($themeCode) { foreach ($this->themes as $code => $theme) { - if ($theme->hasParent() AND $theme->getParentName() == $themeCode) + if ($theme->hasParent() && $theme->getParentName() == $themeCode) return TRUE; } @@ -546,11 +546,11 @@ public function extractTheme($zipPath) } $meta = @json_decode($zip->getFromName($themeDir.'theme.json')); - if (!$meta OR !strlen($meta->code)) + if (!$meta || !strlen($meta->code)) throw new SystemException(lang('system::lang.themes.error_config_no_found')); $themeCode = $meta->code; - if (!$this->checkName($themeDir) OR !$this->checkName($themeCode)) + if (!$this->checkName($themeDir) || !$this->checkName($themeCode)) throw new SystemException('Theme directory name can not have spaces.'); $extractToPath = $themesFolder.'/'.$themeCode; diff --git a/app/main/formwidgets/TemplateEditor.php b/app/main/formwidgets/TemplateEditor.php index 4e6ad5fe0b..1ab7dd4b45 100644 --- a/app/main/formwidgets/TemplateEditor.php +++ b/app/main/formwidgets/TemplateEditor.php @@ -208,7 +208,7 @@ protected function makeTemplateFormWidget() protected function getTemplateEditorOptions() { - if (!$themeObject = $this->model->getTheme() OR !$themeObject instanceof Theme) + if (!($themeObject = $this->model->getTheme()) || !$themeObject instanceof Theme) throw new ApplicationException('Missing theme object on '.get_class($this->model)); $type = $this->templateType ?? '_pages'; diff --git a/app/main/template/Model.php b/app/main/template/Model.php index 1a80036760..45520ed182 100644 --- a/app/main/template/Model.php +++ b/app/main/template/Model.php @@ -187,7 +187,7 @@ public function getFilePath($fileName = null) $fileName = $this->getTypeDirName().'/'.$fileName; - if ($this->theme->hasParent() AND File::exists($this->theme->getParentPath().'/'.$fileName)) + if ($this->theme->hasParent() && File::exists($this->theme->getParentPath().'/'.$fileName)) return $this->theme->getParentPath().'/'.$fileName; return $this->theme->getPath().'/'.$fileName; @@ -259,7 +259,7 @@ public function getTemplateCacheKey() */ public function __get($name) { - if (is_array($this->settings) AND array_key_exists($name, $this->settings)) { + if (is_array($this->settings) && array_key_exists($name, $this->settings)) { return $this->settings[$name]; } diff --git a/app/main/template/concerns/HasComponents.php b/app/main/template/concerns/HasComponents.php index eaabde3440..5691f4ca00 100644 --- a/app/main/template/concerns/HasComponents.php +++ b/app/main/template/concerns/HasComponents.php @@ -112,7 +112,7 @@ public function updateComponent($alias, array $properties) $attributes = $this->attributes; $newAlias = array_get($properties, 'alias'); - if ($newAlias AND $newAlias !== $alias) { + if ($newAlias && $newAlias !== $alias) { $attributes = array_replace_key($attributes, $alias, $newAlias); $alias = $newAlias; } diff --git a/app/main/widgets/MediaManager.php b/app/main/widgets/MediaManager.php index 24b8882a03..2efb070a01 100644 --- a/app/main/widgets/MediaManager.php +++ b/app/main/widgets/MediaManager.php @@ -277,7 +277,7 @@ public function onRenameFile() if (!$mediaLibrary->isAllowedExtension($name)) throw new ApplicationException(lang('main::lang.media_manager.alert_extension_not_allowed')); - if (!$this->validateFileName($name) OR !$this->validateFileName($oldName)) + if (!$this->validateFileName($name) || !$this->validateFileName($oldName)) throw new ApplicationException(lang('main::lang.media_manager.alert_invalid_file_name')); $newPath = $path.'/'.$name; @@ -336,7 +336,7 @@ public function onDeleteFiles() throw new ApplicationException(lang('main::lang.media_manager.alert_invalid_path')); $files = post('files'); - if (empty($files) OR !is_array($files)) { + if (empty($files) || !is_array($files)) { throw new ApplicationException(lang('main::lang.media_manager.alert_select_delete_file')); } @@ -374,7 +374,7 @@ public function onMoveFiles() throw new ApplicationException(lang('main::lang.media_manager.alert_invalid_path')); $files = post('files'); - if (empty($files) OR !is_array($files)) + if (empty($files) || !is_array($files)) throw new ApplicationException(lang('main::lang.media_manager.alert_select_move_file')); foreach ($files as $file) { @@ -411,7 +411,7 @@ public function onCopyFiles() throw new ApplicationException(lang('main::lang.media_manager.alert_invalid_path')); $files = post('files'); - if (empty($files) OR !is_array($files)) + if (empty($files) || !is_array($files)) throw new ApplicationException(lang('main::lang.media_manager.alert_select_copy_file')); foreach ($files as $file) { @@ -530,7 +530,7 @@ protected function setSortBy($sortBy) { $sort = $this->getSortBy(); $direction = 'descending'; - if ($sort AND in_array($direction, $sort)) + if ($sort && in_array($direction, $sort)) $direction = 'ascending'; $sortBy = [$sortBy, $direction]; @@ -545,7 +545,7 @@ protected function getSortBy() protected function checkUploadHandler() { - if (!($uniqueId = Request::header('X-IGNITER-FILEUPLOAD')) OR $uniqueId != $this->getId()) + if (!($uniqueId = Request::header('X-IGNITER-FILEUPLOAD')) || $uniqueId != $this->getId()) return; $mediaLibrary = $this->getMediaLibrary(); @@ -637,7 +637,7 @@ protected function makeReadableSize($size) $units = ['B', 'KB', 'MB', 'GB', 'TB']; $u = 0; - while ((round($size / 1024) > 0) AND ($u < 4)) { + while ((round($size / 1024) > 0) && ($u < 4)) { $size = $size / 1024; $u++; } diff --git a/app/main/widgets/mediamanager/list_grid.blade.php b/app/main/widgets/mediamanager/list_grid.blade.php index 1d8efee75e..a4e40c7e4a 100644 --- a/app/main/widgets/mediamanager/list_grid.blade.php +++ b/app/main/widgets/mediamanager/list_grid.blade.php @@ -13,7 +13,7 @@ class="media-thumb" data-media-item-dimension="{{ isset($item->thumb['dimension']) ? $item['thumb']['dimension'] : '--' }}" data-media-item-folder="{{ $currentFolder }}" data-media-item-data='@json($item)' - @if ($item->name == $selectItem OR $loop->iteration == 0) data-media-item-marked=""@endif + @if ($item->name == $selectItem || $loop->iteration == 0) data-media-item-marked=""@endif >
  • @lang('main::lang.media_manager.label_permission') : - @if ($file['perms'] === '04' OR $file['perms'] === '05') + @if ($file['perms'] === '04' || $file['perms'] === '05') @lang('main::lang.media_manager.text_read_only') - @elseif ($file['perms'] === '06' OR $file['perms'] === '07') + @elseif ($file['perms'] === '06' || $file['perms'] === '07') @lang('main::lang.media_manager.text_read_write') @else @lang('main::lang.media_manager.text_no_access') diff --git a/app/main/widgets/mediamanager/toolbar.blade.php b/app/main/widgets/mediamanager/toolbar.blade.php index 01fce52a3c..80eda43558 100644 --- a/app/main/widgets/mediamanager/toolbar.blade.php +++ b/app/main/widgets/mediamanager/toolbar.blade.php @@ -65,7 +65,7 @@ class="btn btn-danger" title="@lang('main::lang.media_manager.text_delete_folder