@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * @return mixed |
|
126 | + * @return string |
|
127 | 127 | */ |
128 | 128 | public function getValue() |
129 | 129 | { |
@@ -162,6 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | /** |
164 | 164 | * |
165 | + * @param boolean $value |
|
165 | 166 | */ |
166 | 167 | public function hideValue($value = null) |
167 | 168 | { |
@@ -174,6 +175,7 @@ discard block |
||
174 | 175 | |
175 | 176 | /** |
176 | 177 | * |
178 | + * @param boolean $value |
|
177 | 179 | */ |
178 | 180 | public function saveIfEmpty($value = null) |
179 | 181 | { |
@@ -186,6 +188,7 @@ discard block |
||
186 | 188 | |
187 | 189 | /** |
188 | 190 | * |
191 | + * @param boolean $value |
|
189 | 192 | */ |
190 | 193 | public function noValidate($value = null) |
191 | 194 | { |
@@ -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 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | { |
6 | 6 | public function getConfigValue() |
7 | 7 | { |
8 | - if (! property_exists($this, 'config') || ! is_array($this->config) || empty($this->config)) { |
|
8 | + if (!property_exists($this, 'config') || !is_array($this->config) || empty($this->config)) { |
|
9 | 9 | return null; |
10 | 10 | } |
11 | 11 | |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | if (is_array($params) && count($params) > 0) { |
19 | 19 | foreach ($params as $configKey) { |
20 | - if (! array_key_exists($configKey, $nestedConfig)) { |
|
20 | + if (!array_key_exists($configKey, $nestedConfig)) { |
|
21 | 21 | $nestedConfig = array(); |
22 | 22 | return null; |
23 | 23 | } |
@@ -103,7 +103,7 @@ |
||
103 | 103 | { |
104 | 104 | $results = $this->eloquentRelation->getResults(); |
105 | 105 | |
106 | - if (! empty($results)) { |
|
106 | + if (!empty($results)) { |
|
107 | 107 | $field->setValue($results->getKey()); |
108 | 108 | } |
109 | 109 | return $field; |
@@ -8,7 +8,7 @@ |
||
8 | 8 | { |
9 | 9 | public function checkRelationCompatibility() |
10 | 10 | { |
11 | - if (! in_array(get_class($this->eloquentRelation), $this->compatibleEloquentRelations)) { |
|
11 | + if (!in_array(get_class($this->eloquentRelation), $this->compatibleEloquentRelations)) { |
|
12 | 12 | throw new RelationException(get_class($this->eloquentRelation)." eloquent relation is not compatible with ".$this->getType()." type"); |
13 | 13 | } |
14 | 14 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | public function get($name) |
74 | 74 | { |
75 | - if (! empty($this->config) && ! empty($this->config['name'])) { |
|
75 | + if (!empty($this->config) && !empty($this->config['name'])) { |
|
76 | 76 | $name = $this->config['name']; |
77 | 77 | } |
78 | - if (! method_exists($this->model, $name)) { |
|
79 | - throw new FactoryException("Relation " . $name . " does not exist on " . get_class($this->model)); |
|
78 | + if (!method_exists($this->model, $name)) { |
|
79 | + throw new FactoryException("Relation ".$name." does not exist on ".get_class($this->model)); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $relationInstance = $this->model->$name(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | |
85 | 85 | |
86 | 86 | if (empty($this->config['type'])) { |
87 | - if (! array_key_exists($relationEloquentType, $this->eloquentTypeToRelationType)) { |
|
88 | - throw new FactoryException($relationEloquentType . " relation not supported"); |
|
87 | + if (!array_key_exists($relationEloquentType, $this->eloquentTypeToRelationType)) { |
|
88 | + throw new FactoryException($relationEloquentType." relation not supported"); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $type = $this->eloquentTypeToRelationType[$relationEloquentType]; |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | $type = $this->config['type']; |
94 | 94 | } |
95 | 95 | |
96 | - if (! array_key_exists($type, $this->typesMap)) { |
|
97 | - throw new FactoryException("Unexpected relation type: " . $type); |
|
96 | + if (!array_key_exists($type, $this->typesMap)) { |
|
97 | + throw new FactoryException("Unexpected relation type: ".$type); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->config['name'] = $name; |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->app->bind( |
49 | 49 | 'Anavel\Crud\Contracts\Abstractor\FieldFactory', |
50 | - function () { |
|
50 | + function() { |
|
51 | 51 | return new FieldAbstractorFactory(new FormFactory); |
52 | 52 | } |
53 | 53 | ); |
54 | 54 | |
55 | 55 | $this->app->bind( |
56 | 56 | 'Anavel\Crud\Contracts\Abstractor\RelationFactory', |
57 | - function () { |
|
57 | + function() { |
|
58 | 58 | return new RelationAbstractorFactory( |
59 | 59 | $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'], |
60 | 60 | $this->app['Anavel\Crud\Contracts\Abstractor\FieldFactory'] |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $this->app->bind( |
66 | 66 | 'Anavel\Crud\Contracts\Abstractor\ModelFactory', |
67 | - function () { |
|
67 | + function() { |
|
68 | 68 | return new ModelAbstractorFactory( |
69 | 69 | config('anavel-crud.models'), |
70 | 70 | $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'], |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $this->app->bind( |
79 | 79 | 'Anavel\Crud\Contracts\Form\Generator', |
80 | - function () { |
|
80 | + function() { |
|
81 | 81 | return new FormGenerator(new FormFactory); |
82 | 82 | } |
83 | 83 | ); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | 'prefix' => 'crud', |
6 | 6 | 'namespace' => 'Anavel\Crud\Http\Controllers' |
7 | 7 | ], |
8 | - function () { |
|
8 | + function() { |
|
9 | 9 | Route::get('/', [ |
10 | 10 | 'as' => 'anavel-crud.home', |
11 | 11 | 'uses' => 'HomeController@index' |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use EasySlugger\Slugger; |
4 | 4 | |
5 | -if (! function_exists('slugify')) { |
|
5 | +if (!function_exists('slugify')) { |
|
6 | 6 | /** |
7 | 7 | * Generate slug |
8 | 8 | * |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | -if (! function_exists('uniqueSlugify')) { |
|
18 | +if (!function_exists('uniqueSlugify')) { |
|
19 | 19 | /** |
20 | 20 | * Generate unique slug |
21 | 21 | * |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -if (! function_exists('transcrud')) { |
|
31 | +if (!function_exists('transcrud')) { |
|
32 | 32 | /** |
33 | 33 | * Translate string but remove file key if translation not found |
34 | 34 | * |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function transcrud($text) |
39 | 39 | { |
40 | - $translation = trans('anavel-crud::models.' . $text); |
|
40 | + $translation = trans('anavel-crud::models.'.$text); |
|
41 | 41 | |
42 | 42 | return str_replace('anavel-crud::models.', '', $translation); |
43 | 43 | } |
@@ -85,6 +85,9 @@ discard block |
||
85 | 85 | return transcrud($this->name); |
86 | 86 | } |
87 | 87 | |
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
88 | 91 | public function getModel() |
89 | 92 | { |
90 | 93 | return $this->model; |
@@ -334,7 +337,7 @@ discard block |
||
334 | 337 | } |
335 | 338 | |
336 | 339 | /** |
337 | - * @param array $requestForm |
|
340 | + * @param array $request |
|
338 | 341 | * @return mixed |
339 | 342 | */ |
340 | 343 | public function persist(Request $request) |
@@ -128,32 +128,32 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | $customDisplayedColumns = $this->getConfigValue($action, 'display'); |
131 | - $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : []; |
|
131 | + $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: []; |
|
132 | 132 | |
133 | 133 | $relations = $this->getRelations(); |
134 | 134 | |
135 | 135 | $columns = array(); |
136 | - if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
136 | + if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
137 | 137 | foreach ($customDisplayedColumns as $customColumn) { |
138 | 138 | if (strpos($customColumn, '.')) { |
139 | 139 | $customColumnRelation = explode('.', $customColumn); |
140 | 140 | |
141 | - if (! $relations->has($customColumnRelation[0])) { |
|
142 | - throw new AbstractorException("Relation " . $customColumnRelation[0] . " not configured on " . $this->getModel()); |
|
141 | + if (!$relations->has($customColumnRelation[0])) { |
|
142 | + throw new AbstractorException("Relation ".$customColumnRelation[0]." not configured on ".$this->getModel()); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $relation = $relations->get($customColumnRelation[0]); |
146 | 146 | |
147 | 147 | $relationColumns = $relation->getModelAbstractor()->getColumns($action); |
148 | 148 | |
149 | - if (! array_key_exists($customColumnRelation[1], $relationColumns)) { |
|
150 | - throw new AbstractorException("Column " . $customColumnRelation[1] . " does not exist on relation ".$customColumnRelation[0]. " of model " . $this->getModel()); |
|
149 | + if (!array_key_exists($customColumnRelation[1], $relationColumns)) { |
|
150 | + throw new AbstractorException("Column ".$customColumnRelation[1]." does not exist on relation ".$customColumnRelation[0]." of model ".$this->getModel()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $columns[$customColumn] = $relationColumns[$customColumnRelation[1]]; |
154 | 154 | } else { |
155 | - if (! array_key_exists($customColumn, $tableColumns)) { |
|
156 | - throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel()); |
|
155 | + if (!array_key_exists($customColumn, $tableColumns)) { |
|
156 | + throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel()); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $columns[$customColumn] = $tableColumns[$customColumn]; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | $relations = collect(); |
187 | 187 | |
188 | - if (! empty($configRelations)) { |
|
188 | + if (!empty($configRelations)) { |
|
189 | 189 | foreach ($configRelations as $relationName => $configRelation) { |
190 | 190 | if (is_int($relationName)) { |
191 | 191 | $relationName = $configRelation; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | $config = []; |
195 | 195 | if ($configRelation !== $relationName) { |
196 | - if (! is_array($configRelation)) { |
|
196 | + if (!is_array($configRelation)) { |
|
197 | 197 | $config['type'] = $configRelation; |
198 | 198 | } else { |
199 | 199 | $config = $configRelation; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $secondaryRelations = $relation->getSecondaryRelations(); |
209 | 209 | |
210 | 210 | |
211 | - if (! $secondaryRelations->isEmpty()) { |
|
211 | + if (!$secondaryRelations->isEmpty()) { |
|
212 | 212 | $relations->put( |
213 | 213 | $relationName, |
214 | 214 | collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations]) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | $columns = $this->getColumns('list'); |
234 | 234 | |
235 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
235 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
236 | 236 | |
237 | 237 | $fields = array(); |
238 | 238 | foreach ($columns as $name => $column) { |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | $columns = $this->getColumns('detail'); |
269 | 269 | |
270 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
270 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
271 | 271 | |
272 | 272 | $fields = array(); |
273 | 273 | foreach ($columns as $name => $column) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | $fields = array(); |
309 | 309 | foreach ($columns as $name => $column) { |
310 | - if (! in_array($name, $this->getReadOnlyColumns())) { |
|
310 | + if (!in_array($name, $this->getReadOnlyColumns())) { |
|
311 | 311 | $presentation = null; |
312 | 312 | if (array_key_exists($name, $this->fieldsPresentation)) { |
313 | 313 | $presentation = $this->fieldsPresentation[$name]; |
@@ -328,24 +328,24 @@ discard block |
||
328 | 328 | ->setConfig($config) |
329 | 329 | ->get(); |
330 | 330 | |
331 | - if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) { |
|
331 | + if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) { |
|
332 | 332 | $field->setValue($this->instance->getAttribute($name)); |
333 | 333 | } |
334 | 334 | |
335 | 335 | $fields[$arrayKey][$name] = $field; |
336 | 336 | |
337 | - if (! empty($config['form_type']) && $config['form_type'] === 'file') { |
|
337 | + if (!empty($config['form_type']) && $config['form_type'] === 'file') { |
|
338 | 338 | $field = $this->fieldFactory |
339 | 339 | ->setColumn($column) |
340 | 340 | ->setConfig([ |
341 | - 'name' => $name . '__delete', |
|
341 | + 'name' => $name.'__delete', |
|
342 | 342 | 'presentation' => null, |
343 | 343 | 'form_type' => 'checkbox', |
344 | 344 | 'no_validate' => true, |
345 | 345 | 'functions' => null |
346 | 346 | ]) |
347 | 347 | ->get(); |
348 | - $fields[$arrayKey][$name . '__delete'] = $field; |
|
348 | + $fields[$arrayKey][$name.'__delete'] = $field; |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | { |
383 | 383 | /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */ |
384 | 384 | $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'); |
385 | - if (! empty($this->instance)) { |
|
385 | + if (!empty($this->instance)) { |
|
386 | 386 | $item = $this->instance; |
387 | 387 | } else { |
388 | 388 | $item = $modelManager->getModelInstance($this->getModel()); |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if (! empty($fields['main'])) { |
|
397 | + if (!empty($fields['main'])) { |
|
398 | 398 | $skip = null; |
399 | 399 | foreach ($fields['main'] as $key => $field) { |
400 | 400 | /** @var FieldContract $field */ |
@@ -419,20 +419,20 @@ discard block |
||
419 | 419 | |
420 | 420 | if (get_class($field->getFormField()) === \FormManager\Fields\File::class) { |
421 | 421 | $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName); |
422 | - if (! empty($handleResult['skip'])) { |
|
422 | + if (!empty($handleResult['skip'])) { |
|
423 | 423 | $skip = $handleResult['skip']; |
424 | 424 | } |
425 | - if (! empty($handleResult['requestValue'])) { |
|
425 | + if (!empty($handleResult['requestValue'])) { |
|
426 | 426 | $requestValue = $handleResult['requestValue']; |
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | - if (! $field->saveIfEmpty() && empty($requestValue)) { |
|
431 | + if (!$field->saveIfEmpty() && empty($requestValue)) { |
|
432 | 432 | continue; |
433 | 433 | } |
434 | 434 | |
435 | - if (! empty($requestValue) || (empty($requestValue) && ! empty($item->getAttribute($fieldName)))) { |
|
435 | + if (!empty($requestValue) || (empty($requestValue) && !empty($item->getAttribute($fieldName)))) { |
|
436 | 436 | $item->setAttribute( |
437 | 437 | $fieldName, |
438 | 438 | $field->applyFunctions($requestValue) |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | $this->setInstance($item); |
447 | 447 | |
448 | 448 | |
449 | - if (! empty($relations = $this->getRelations())) { |
|
449 | + if (!empty($relations = $this->getRelations())) { |
|
450 | 450 | foreach ($relations as $relationKey => $relation) { |
451 | 451 | if ($relation instanceof Collection) { |
452 | 452 | $input = $request->input($relationKey); |