@@ -28,7 +28,7 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function persist(array $relationArray = null, Request $request) |
| 30 | 30 | { |
| 31 | - if (! empty($relationArray)) { |
|
| 31 | + if (!empty($relationArray)) { |
|
| 32 | 32 | $this->eloquentRelation->sync($relationArray[$this->eloquentRelation->getRelated()->getKeyName()]); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $translationFields = []; |
| 49 | - if (! empty($columns)) { |
|
| 49 | + if (!empty($columns)) { |
|
| 50 | 50 | foreach ($this->langs as $key => $lang) { |
| 51 | 51 | $tempFields = []; |
| 52 | 52 | foreach ($columns as $columnName => $column) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $config = [ |
| 68 | 68 | 'name' => $columnName, |
| 69 | - 'presentation' => ucfirst(transcrud($columnName)) . ' [' . $lang . ']', |
|
| 69 | + 'presentation' => ucfirst(transcrud($columnName)).' ['.$lang.']', |
|
| 70 | 70 | 'form_type' => $formType, |
| 71 | 71 | 'no_validate' => true, |
| 72 | 72 | 'validation' => null, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function persist(array $relationArray = null, Request $request) |
| 108 | 108 | { |
| 109 | - if (! empty($relationArray)) { |
|
| 109 | + if (!empty($relationArray)) { |
|
| 110 | 110 | $currentTranslations = $this->eloquentRelation->getResults(); |
| 111 | 111 | $currentTranslations = $currentTranslations->keyBy('locale'); |
| 112 | 112 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | private function customController(Model $modelAbstractor) |
| 40 | 40 | { |
| 41 | - if (! $this instanceof CustomController) { //Avoid infinite recursion |
|
| 42 | - if (array_key_exists('controller', $config = $modelAbstractor->getConfig()) && (! empty($config['controller']))) { |
|
| 41 | + if (!$this instanceof CustomController) { //Avoid infinite recursion |
|
| 42 | + if (array_key_exists('controller', $config = $modelAbstractor->getConfig()) && (!empty($config['controller']))) { |
|
| 43 | 43 | /** @var CustomController $controller */ |
| 44 | 44 | $controller = App::make($config['controller']); |
| 45 | 45 | $controller->setAbstractor($modelAbstractor); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $this->authorizeMethod($modelAbstractor, 'adminIndex'); |
| 64 | 64 | |
| 65 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 65 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 66 | 66 | return $customController->index($request, $model); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $this->authorizeMethod($modelAbstractor, 'adminCreate'); |
| 104 | 104 | |
| 105 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 105 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 106 | 106 | return $customController->create($model); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $this->authorizeMethod($modelAbstractor, 'adminStore'); |
| 130 | 130 | |
| 131 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 131 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 132 | 132 | return $customController->store($request, $model); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $this->authorizeMethod($modelAbstractor, 'adminShow'); |
| 164 | 164 | |
| 165 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 165 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 166 | 166 | return $customController->show($model, $id); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $this->authorizeMethod($modelAbstractor, 'adminEdit'); |
| 191 | 191 | |
| 192 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 192 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 193 | 193 | return $customController->edit($model, $id); |
| 194 | 194 | } |
| 195 | 195 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | $this->authorizeMethod($modelAbstractor, 'adminUpdate'); |
| 221 | 221 | |
| 222 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 222 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 223 | 223 | return $customController->update($request, $model, $id); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $this->authorizeMethod($modelAbstractor, 'adminDestroy'); |
| 256 | 256 | |
| 257 | - if (! empty($customController = $this->customController($modelAbstractor))) { |
|
| 257 | + if (!empty($customController = $this->customController($modelAbstractor))) { |
|
| 258 | 258 | return $customController->destroy($request, $model, $id); |
| 259 | 259 | } |
| 260 | 260 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | $modelAbstractor = $modelFactory->getByName($modelSlug); |
| 24 | 24 | $config = $modelAbstractor->getConfig(); |
| 25 | 25 | |
| 26 | - if (! array_key_exists('authorize', $config) || ($config['authorize'] === true && Gate::allows('adminIndex', $modelAbstractor->getInstance()) || $config['authorize'] === false)) { |
|
| 26 | + if (!array_key_exists('authorize', $config) || ($config['authorize'] === true && Gate::allows('adminIndex', $modelAbstractor->getInstance()) || $config['authorize'] === false)) { |
|
| 27 | 27 | return new RedirectResponse(route('anavel-crud.model.index', $modelSlug)); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -60,13 +60,13 @@ |
||
| 60 | 60 | } catch (\Exception $e) { |
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | - $menuItems[$modelName]['isActive'] = $item['isActive']; |
|
| 63 | + $menuItems[$modelName]['isActive'] = $item['isActive']; |
|
| 64 | 64 | $menuItems[$modelName]['name'] = $item['name']; |
| 65 | 65 | $menuItems[$modelName]['items'][] = $item; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | //Sort alphabetically de menu items |
| 69 | - usort($menuItems, function ($itemA, $itemB) { |
|
| 69 | + usort($menuItems, function($itemA, $itemB) { |
|
| 70 | 70 | return strcmp($itemA['name'], $itemB['name']); |
| 71 | 71 | }); |
| 72 | 72 | return $menuItems; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $this->readConfig('edit'); |
| 50 | 50 | |
| 51 | - if (! empty($columns)) { |
|
| 51 | + if (!empty($columns)) { |
|
| 52 | 52 | //Add field for model deletion |
| 53 | 53 | $config = [ |
| 54 | 54 | 'name' => '__delete', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $config = [ |
| 76 | 76 | 'name' => $columnName, |
| 77 | - 'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)), |
|
| 77 | + 'presentation' => $this->name.' '.ucfirst(transcrud($columnName)), |
|
| 78 | 78 | 'form_type' => $formType, |
| 79 | 79 | 'no_validate' => true, |
| 80 | 80 | 'validation' => null, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ->setConfig($config) |
| 90 | 90 | ->get(); |
| 91 | 91 | |
| 92 | - if (! empty($result->id)) { |
|
| 92 | + if (!empty($result->id)) { |
|
| 93 | 93 | $field->setValue($result->getAttribute($columnName)); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function persist(array $relationArray = null, Request $request) |
| 111 | 111 | { |
| 112 | - if (! empty($relationArray)) { |
|
| 112 | + if (!empty($relationArray)) { |
|
| 113 | 113 | $currentRelation = $this->eloquentRelation->getResults(); |
| 114 | - if (! empty($currentRelation)) { |
|
| 114 | + if (!empty($currentRelation)) { |
|
| 115 | 115 | $relationModel = $currentRelation; |
| 116 | 116 | } else { |
| 117 | 117 | $relationModel = $this->eloquentRelation->getRelated()->newInstance(); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $relationModel->setAttribute($fieldKey, $fieldValue); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if (! $shouldBeSkipped) { |
|
| 136 | + if (!$shouldBeSkipped) { |
|
| 137 | 137 | $relationModel->save(); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public function setFunctions($functions) |
| 108 | 108 | { |
| 109 | - if (! is_array($functions)) { |
|
| 109 | + if (!is_array($functions)) { |
|
| 110 | 110 | $functions = array($functions); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | public function applyFunctions($value) |
| 117 | 117 | { |
| 118 | 118 | foreach ($this->functions as $function) { |
| 119 | - if (! function_exists($function)) { |
|
| 119 | + if (!function_exists($function)) { |
|
| 120 | 120 | throw new \Exception("Function ".$function." does not exist"); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $this->value = $value; |
| 136 | 136 | |
| 137 | - if (! $this->hideValue()) { |
|
| 137 | + if (!$this->hideValue()) { |
|
| 138 | 138 | $this->formField->val($this->value); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | public function getFormField() |
| 170 | 170 | { |
| 171 | - if (! $this->hideValue()) { |
|
| 171 | + if (!$this->hideValue()) { |
|
| 172 | 172 | if (Request::old($this->name)) { |
| 173 | 173 | $this->formField->val(Request::old($this->name)); |
| 174 | 174 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function hideValue($value = null) |
| 184 | 184 | { |
| 185 | - if (! is_null($value)) { |
|
| 185 | + if (!is_null($value)) { |
|
| 186 | 186 | $this->hideValue = $value; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function saveIfEmpty($value = null) |
| 196 | 196 | { |
| 197 | - if (! is_null($value)) { |
|
| 197 | + if (!is_null($value)) { |
|
| 198 | 198 | $this->saveIfEmpty = $value; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function noValidate($value = null) |
| 208 | 208 | { |
| 209 | - if (! is_null($value)) { |
|
| 209 | + if (!is_null($value)) { |
|
| 210 | 210 | $this->noValidate = $value; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $field = new Field($this->column, $formElement, $this->config['name'], $this->config['presentation']); |
| 82 | 82 | |
| 83 | - if (! empty($this->config['validation'])) { |
|
| 83 | + if (!empty($this->config['validation'])) { |
|
| 84 | 84 | if ($this->config['validation'] === 'no_validate') { |
| 85 | 85 | $this->config['no_validate'] = true; |
| 86 | 86 | } else { |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (! empty($this->config['functions'])) { |
|
| 91 | + if (!empty($this->config['functions'])) { |
|
| 92 | 92 | $field->setFunctions($this->config['functions']); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if (! empty($this->config['no_validate']) && $this->config['no_validate'] === true) { |
|
| 95 | + if (!empty($this->config['no_validate']) && $this->config['no_validate'] === true) { |
|
| 96 | 96 | $field->noValidate(true); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -117,15 +117,15 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | protected function getFormElement() |
| 119 | 119 | { |
| 120 | - if (! empty($this->config['form_type'])) { |
|
| 121 | - if (! in_array($this->config['form_type'], $this->databaseTypeToFormType)) { |
|
| 122 | - throw new FactoryException("Unknown form type " . $this->config['form_type']); |
|
| 120 | + if (!empty($this->config['form_type'])) { |
|
| 121 | + if (!in_array($this->config['form_type'], $this->databaseTypeToFormType)) { |
|
| 122 | + throw new FactoryException("Unknown form type ".$this->config['form_type']); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $formElementType = $this->config['form_type']; |
| 126 | 126 | } else { |
| 127 | - if (! array_key_exists($this->column->getType()->getName(), $this->databaseTypeToFormType)) { |
|
| 128 | - throw new FactoryException("No form type found for database type " . $this->column->getType()->getName()); |
|
| 127 | + if (!array_key_exists($this->column->getType()->getName(), $this->databaseTypeToFormType)) { |
|
| 128 | + throw new FactoryException("No form type found for database type ".$this->column->getType()->getName()); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | $formElementType = $this->databaseTypeToFormType[$this->column->getType()->getName()]; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | $formElement = $this->factory->get($formElementType, []); |
| 140 | 140 | |
| 141 | - if (! empty($this->config['attr']) && is_array($this->config['attr'])) { |
|
| 141 | + if (!empty($this->config['attr']) && is_array($this->config['attr'])) { |
|
| 142 | 142 | $formElement->attr($this->config['attr']); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if ($formElementType === 'textarea') { |
| 152 | - $formElement->class('form-control ' . config('anavel-crud.text_editor')); |
|
| 152 | + $formElement->class('form-control '.config('anavel-crud.text_editor')); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if ($formElementType === 'checkbox') { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | if (isset($this->config['defaults'])) { |
| 160 | - if (! is_array($this->config['defaults'])) { |
|
| 160 | + if (!is_array($this->config['defaults'])) { |
|
| 161 | 161 | $formElement->val(transcrud($this->config['defaults'])); |
| 162 | 162 | } else { |
| 163 | 163 | $defaults = []; |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | */ |
| 84 | 84 | public function getDisplay() |
| 85 | 85 | { |
| 86 | - if (! empty($this->config['display'])) { |
|
| 86 | + if (!empty($this->config['display'])) { |
|
| 87 | 87 | return $this->config['display']; |
| 88 | 88 | } |
| 89 | 89 | return null; |