@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function getEditFields($arrayKey = null) |
28 | 28 | { |
29 | - if(empty($arrayKey)) { |
|
29 | + if (empty($arrayKey)) { |
|
30 | 30 | $arrayKey = $this->name; |
31 | 31 | } |
32 | 32 | |
@@ -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 | foreach ($columns as $columnName => $column) { |
53 | 53 | if (in_array($columnName, $readOnly, true)) { |
54 | 54 | continue; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $config = [ |
60 | 60 | 'name' => $columnName, |
61 | - 'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)), |
|
61 | + 'presentation' => $this->name.' '.ucfirst(transcrud($columnName)), |
|
62 | 62 | 'form_type' => $formType, |
63 | 63 | 'no_validate' => true, |
64 | 64 | 'validation' => null, |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ->setConfig($config) |
74 | 74 | ->get(); |
75 | 75 | |
76 | - if (! empty($result->id)) { |
|
76 | + if (!empty($result->id)) { |
|
77 | 77 | $field->setValue($result->getAttribute($columnName)); |
78 | 78 | } |
79 | 79 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function persist(array $relationArray = null) |
95 | 95 | { |
96 | - if (! empty($relationArray)) { |
|
96 | + if (!empty($relationArray)) { |
|
97 | 97 | $currentRelation = $this->eloquentRelation->getResults(); |
98 | - if (! empty($currentRelation)) { |
|
98 | + if (!empty($currentRelation)) { |
|
99 | 99 | $relationModel = $currentRelation; |
100 | 100 | } else { |
101 | 101 | $relationModel = $this->eloquentRelation->getRelated()->newInstance(); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $relationModel->setAttribute($fieldKey, $fieldValue); |
112 | 112 | } |
113 | 113 | |
114 | - if (! $shouldBeSkipped) { |
|
114 | + if (!$shouldBeSkipped) { |
|
115 | 115 | $relationModel->save(); |
116 | 116 | } |
117 | 117 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->readConfig('edit'); |
42 | 42 | |
43 | - if(empty($arrayKey)) { |
|
43 | + if (empty($arrayKey)) { |
|
44 | 44 | $arrayKey = $this->name; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $translationFields = []; |
48 | - if (! empty($columns)) { |
|
48 | + if (!empty($columns)) { |
|
49 | 49 | foreach ($this->langs as $key => $lang) { |
50 | 50 | $tempFields = []; |
51 | 51 | foreach ($columns as $columnName => $column) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | $config = [ |
67 | 67 | 'name' => $columnName, |
68 | - 'presentation' => ucfirst(transcrud($columnName)).' ['.$lang .']', |
|
68 | + 'presentation' => ucfirst(transcrud($columnName)).' ['.$lang.']', |
|
69 | 69 | 'form_type' => $formType, |
70 | 70 | 'no_validate' => true, |
71 | 71 | 'validation' => null, |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function persist(array $relationArray = null) |
107 | 107 | { |
108 | - if (! empty($relationArray)) { |
|
108 | + if (!empty($relationArray)) { |
|
109 | 109 | $currentTranslations = $this->eloquentRelation->get(); |
110 | 110 | $currentTranslations = $currentTranslations->keyBy('locale'); |
111 | 111 |
@@ -17,11 +17,11 @@ |
||
17 | 17 | */ |
18 | 18 | public function readConfig($action) |
19 | 19 | { |
20 | - $this->fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
21 | - $this->formTypes = $this->getConfigValue($action, 'form_types') ? : []; |
|
22 | - $this->validationRules = $this->getConfigValue($action, 'validation') ? : []; |
|
23 | - $this->functions = $this->getConfigValue($action, 'functions') ? : []; |
|
24 | - $this->defaults = $this->getConfigValue($action, 'defaults') ? : []; |
|
20 | + $this->fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
21 | + $this->formTypes = $this->getConfigValue($action, 'form_types') ?: []; |
|
22 | + $this->validationRules = $this->getConfigValue($action, 'validation') ?: []; |
|
23 | + $this->functions = $this->getConfigValue($action, 'functions') ?: []; |
|
24 | + $this->defaults = $this->getConfigValue($action, 'defaults') ?: []; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $results = $this->eloquentRelation->getResults(); |
45 | 45 | |
46 | 46 | $results->put('emptyResult', ''); |
47 | - if (! empty($columns)) { |
|
47 | + if (!empty($columns)) { |
|
48 | 48 | $readOnly = [Model::CREATED_AT, Model::UPDATED_AT]; |
49 | 49 | foreach ($results as $key => $result) { |
50 | 50 | $tempFields = []; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | $config = [ |
67 | 67 | 'name' => $columnName, |
68 | - 'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)) . ' [' . $index . ']', |
|
68 | + 'presentation' => $this->name.' '.ucfirst(transcrud($columnName)).' ['.$index.']', |
|
69 | 69 | 'form_type' => $formType, |
70 | 70 | 'no_validate' => true, |
71 | 71 | 'validation' => null, |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | $relationModel = $this->eloquentRelation->getRelated()->newInstance(); |
90 | - if (! empty($result)) { |
|
90 | + if (!empty($result)) { |
|
91 | 91 | $relationModel = $result; |
92 | 92 | } |
93 | 93 | $this->modelAbstractor->setInstance($relationModel); |
94 | 94 | $secondaryRelations = $this->getSecondaryRelations(); |
95 | - if (! empty($secondaryRelations)) { |
|
95 | + if (!empty($secondaryRelations)) { |
|
96 | 96 | foreach ($secondaryRelations as $secondaryRelationKey => $secondaryRelation) { |
97 | 97 | foreach ($secondaryRelation->getEditFields($secondaryRelationKey) as $editGroupName => $editGroup) { |
98 | 98 | if ($secondaryRelation->getType() === 'Anavel\Crud\Abstractor\Eloquent\Relation\Select') { |
@@ -119,12 +119,12 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function persist(array $relationArray = null) |
121 | 121 | { |
122 | - if (! empty($relationArray)) { |
|
122 | + if (!empty($relationArray)) { |
|
123 | 123 | $keyName = $this->eloquentRelation->getParent()->getKeyName(); |
124 | 124 | $currentRelations = $this->eloquentRelation->get()->keyBy($keyName); |
125 | 125 | |
126 | 126 | foreach ($relationArray as $relation) { |
127 | - if (! empty($relation[$keyName]) |
|
127 | + if (!empty($relation[$keyName]) |
|
128 | 128 | && ($currentRelations->has($relation[$keyName])) |
129 | 129 | ) { |
130 | 130 | $relationModel = $currentRelations->get($relation[$keyName]); |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | $relationModel->setAttribute($fieldKey, $fieldValue); |
156 | 156 | } |
157 | 157 | |
158 | - if (! $shouldBeSkipped) { |
|
158 | + if (!$shouldBeSkipped) { |
|
159 | 159 | $relationModel->save(); |
160 | 160 | |
161 | - if (! $delayedRelations->isEmpty()) { |
|
161 | + if (!$delayedRelations->isEmpty()) { |
|
162 | 162 | foreach ($delayedRelations as $relationKey => $delayedRelation) { |
163 | 163 | /** @var RelationContract $secondaryRelation */ |
164 | 164 | $secondaryRelation = $secondaryRelations->get($relationKey); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function persist(array $relationArray = null) |
30 | 30 | { |
31 | - if (! empty($relationArray)) { |
|
31 | + if (!empty($relationArray)) { |
|
32 | 32 | /** @var \ANavallaSuiza\Laravel\Database\Contracts\Repository\Repository $repo */ |
33 | 33 | $repo = $this->modelManager->getRepository(get_class($this->eloquentRelation->getRelated())); |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $alreadyAssociated = $this->relatedModel->$relationName; |
38 | 38 | |
39 | 39 | $search = []; |
40 | - if (! empty($relationArray[$relatedKeyName])) { |
|
40 | + if (!empty($relationArray[$relatedKeyName])) { |
|
41 | 41 | $search = $relationArray[$relatedKeyName]; |
42 | 42 | } |
43 | 43 | $results = $repo->pushCriteria( |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $result->save(); |
54 | 54 | } |
55 | 55 | |
56 | - if (! $missing->isEmpty()) { |
|
56 | + if (!$missing->isEmpty()) { |
|
57 | 57 | foreach ($missing as $result) { |
58 | 58 | $result->$keyName = null; |
59 | 59 | $result->save(); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | $results = $this->eloquentRelation->getResults(); |
100 | 100 | |
101 | - if (! $results->isEmpty()) { |
|
101 | + if (!$results->isEmpty()) { |
|
102 | 102 | $values = []; |
103 | 103 | |
104 | 104 | foreach ($results as $result) { |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $customDisplayedColumns = $this->getConfigValue($action, 'display'); |
130 | - $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : []; |
|
130 | + $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: []; |
|
131 | 131 | |
132 | 132 | $columns = array(); |
133 | - if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
133 | + if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
134 | 134 | foreach ($customDisplayedColumns as $customColumn) { |
135 | - if (! array_key_exists($customColumn, $tableColumns)) { |
|
136 | - throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel()); |
|
135 | + if (!array_key_exists($customColumn, $tableColumns)) { |
|
136 | + throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel()); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | $columns[$customColumn] = $tableColumns[$customColumn]; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | $relations = collect(); |
166 | 166 | |
167 | - if (! empty($configRelations)) { |
|
167 | + if (!empty($configRelations)) { |
|
168 | 168 | foreach ($configRelations as $relationName => $configRelation) { |
169 | 169 | if (is_int($relationName)) { |
170 | 170 | $relationName = $configRelation; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $config = []; |
174 | 174 | if ($configRelation !== $relationName) { |
175 | - if (! is_array($configRelation)) { |
|
175 | + if (!is_array($configRelation)) { |
|
176 | 176 | $config['type'] = $configRelation; |
177 | 177 | } else { |
178 | 178 | $config = $configRelation; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $secondaryRelations = $relation->getSecondaryRelations(); |
188 | 188 | |
189 | 189 | |
190 | - if (! $secondaryRelations->isEmpty()) { |
|
190 | + if (!$secondaryRelations->isEmpty()) { |
|
191 | 191 | $relations->put($relationName, |
192 | 192 | collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations])); |
193 | 193 | } else { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $columns = $this->getColumns('list'); |
211 | 211 | |
212 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
212 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
213 | 213 | |
214 | 214 | $fields = array(); |
215 | 215 | foreach ($columns as $name => $column) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | { |
245 | 245 | $columns = $this->getColumns('detail'); |
246 | 246 | |
247 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
247 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
248 | 248 | |
249 | 249 | $fields = array(); |
250 | 250 | foreach ($columns as $name => $column) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | $fields = array(); |
286 | 286 | foreach ($columns as $name => $column) { |
287 | - if (! in_array($name, $this->getReadOnlyColumns())) { |
|
287 | + if (!in_array($name, $this->getReadOnlyColumns())) { |
|
288 | 288 | $presentation = null; |
289 | 289 | if (array_key_exists($name, $this->fieldsPresentation)) { |
290 | 290 | $presentation = $this->fieldsPresentation[$name]; |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | ->setConfig($config) |
306 | 306 | ->get(); |
307 | 307 | |
308 | - if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) { |
|
308 | + if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) { |
|
309 | 309 | $field->setValue($this->instance->getAttribute($name)); |
310 | 310 | } |
311 | 311 | |
312 | 312 | $fields[$arrayKey][] = $field; |
313 | 313 | |
314 | - if (! empty($config['form_type']) && $config['form_type'] === 'file') { |
|
314 | + if (!empty($config['form_type']) && $config['form_type'] === 'file') { |
|
315 | 315 | $field = $this->fieldFactory |
316 | 316 | ->setColumn($column) |
317 | 317 | ->setConfig([ |
318 | - 'name' => $name . '__delete', |
|
318 | + 'name' => $name.'__delete', |
|
319 | 319 | 'presentation' => null, |
320 | 320 | 'form_type' => 'checkbox', |
321 | 321 | 'validation' => null, |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | { |
360 | 360 | /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */ |
361 | 361 | $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'); |
362 | - if (! empty($this->instance)) { |
|
362 | + if (!empty($this->instance)) { |
|
363 | 363 | $item = $this->instance; |
364 | 364 | } else { |
365 | 365 | $item = $modelManager->getModelInstance($this->getModel()); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | return; |
372 | 372 | } |
373 | 373 | |
374 | - if (! empty($fields['main'])) { |
|
374 | + if (!empty($fields['main'])) { |
|
375 | 375 | $skipNext = false; |
376 | 376 | foreach ($fields['main'] as $key => $field) { |
377 | 377 | if ($skipNext === true) { |
@@ -382,19 +382,19 @@ discard block |
||
382 | 382 | |
383 | 383 | if (get_class($field->getFormField()) === \FormManager\Fields\File::class) { |
384 | 384 | $handleResult = $this->handleField($request, $item, $fields, $key, 'main', $fieldName); |
385 | - if (! empty($handleResult['skipNext'])) { |
|
385 | + if (!empty($handleResult['skipNext'])) { |
|
386 | 386 | $skipNext = $handleResult['skipNext']; |
387 | 387 | } |
388 | - if (! empty($handleResult['requestValue'])) { |
|
388 | + if (!empty($handleResult['requestValue'])) { |
|
389 | 389 | $requestValue = $handleResult['requestValue']; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | - if (! $field->saveIfEmpty() && empty($requestValue)) { |
|
393 | + if (!$field->saveIfEmpty() && empty($requestValue)) { |
|
394 | 394 | continue; |
395 | 395 | } |
396 | 396 | |
397 | - if (! empty($requestValue)) { |
|
397 | + if (!empty($requestValue)) { |
|
398 | 398 | $item->setAttribute( |
399 | 399 | $fieldName, |
400 | 400 | $field->applyFunctions($requestValue) |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $this->setInstance($item); |
409 | 409 | |
410 | 410 | |
411 | - if (! empty($relations = $this->getRelations())) { |
|
411 | + if (!empty($relations = $this->getRelations())) { |
|
412 | 412 | foreach ($relations as $relationKey => $relation) { |
413 | 413 | if ($relation instanceof Collection) { |
414 | 414 | $input = $request->input($relationKey); |
@@ -9,19 +9,19 @@ discard block |
||
9 | 9 | |
10 | 10 | trait HandleFiles |
11 | 11 | { |
12 | - protected function handleField(Request $request, $item, array $fields, $currentKey, $groupName, $fieldName) |
|
12 | + protected function handleField(Request $request, $item, array $fields, $currentKey, $groupName, $fieldName) |
|
13 | 13 | { |
14 | - $modelFolder = $this->slug . DIRECTORY_SEPARATOR; |
|
14 | + $modelFolder = $this->slug.DIRECTORY_SEPARATOR; |
|
15 | 15 | $basePath = base_path(config('anavel-crud.uploads_path')); |
16 | - $modelPath = $basePath . $modelFolder; |
|
16 | + $modelPath = $basePath.$modelFolder; |
|
17 | 17 | $skipNext = false; |
18 | 18 | $requestValue = null; |
19 | - if (! empty($fields[$groupName][$currentKey + 1]) && $fields[$groupName][$currentKey + 1]->getName() === $fieldName . '__delete') { |
|
19 | + if (!empty($fields[$groupName][$currentKey + 1]) && $fields[$groupName][$currentKey + 1]->getName() === $fieldName.'__delete') { |
|
20 | 20 | //We never want to save this field, it doesn't exist in the DB |
21 | 21 | $skipNext = true; |
22 | 22 | |
23 | 23 | //If user wants to delete the existing file |
24 | - if (! empty($request->input("main.{$fieldName}__delete"))) { |
|
24 | + if (!empty($request->input("main.{$fieldName}__delete"))) { |
|
25 | 25 | $adapter = new Local($basePath); |
26 | 26 | $filesystem = new Filesystem($adapter); |
27 | 27 | if ($filesystem->has($item->$fieldName)) { |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | } |
41 | - if ($request->hasFile($groupName .'.'.$fieldName)) { |
|
42 | - $fileName = uniqid() . '.' . $request->file($groupName .'.'.$fieldName)->getClientOriginalExtension(); |
|
41 | + if ($request->hasFile($groupName.'.'.$fieldName)) { |
|
42 | + $fileName = uniqid().'.'.$request->file($groupName.'.'.$fieldName)->getClientOriginalExtension(); |
|
43 | 43 | |
44 | 44 | |
45 | - $request->file($groupName .'.'.$fieldName)->move( |
|
45 | + $request->file($groupName.'.'.$fieldName)->move( |
|
46 | 46 | $modelPath, |
47 | 47 | $fileName |
48 | 48 | ); |
49 | 49 | |
50 | - $requestValue = $modelFolder . $fileName; |
|
51 | - } elseif (! empty($request->file($groupName .'.'.$fieldName)) && ! $request->file($groupName .'.'.$fieldName)->isValid()) { |
|
52 | - throw new \Exception($request->file($groupName .'.'.$fieldName)->getErrorMessage()); |
|
50 | + $requestValue = $modelFolder.$fileName; |
|
51 | + } elseif (!empty($request->file($groupName.'.'.$fieldName)) && !$request->file($groupName.'.'.$fieldName)->isValid()) { |
|
52 | + throw new \Exception($request->file($groupName.'.'.$fieldName)->getErrorMessage()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return [ |