@@ -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) |
@@ -16,8 +16,6 @@ |
||
16 | 16 | use Anavel\Crud\Abstractor\Exceptions\AbstractorException; |
17 | 17 | use Illuminate\Http\Request; |
18 | 18 | use Illuminate\Support\Collection; |
19 | -use League\Flysystem\Adapter\Local; |
|
20 | -use League\Flysystem\Filesystem; |
|
21 | 19 | |
22 | 20 | class Model implements ModelAbstractorContract |
23 | 21 | { |
@@ -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); |
@@ -3,8 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility; |
5 | 5 | use Anavel\Crud\Contracts\Abstractor\Field; |
6 | -use App; |
|
7 | -use Illuminate\Http\Request; |
|
8 | 6 | |
9 | 7 | class Translation extends Relation |
10 | 8 | { |
@@ -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 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * @param array $config |
29 | 29 | * @param string $columnName |
30 | - * @return array |
|
30 | + * @return \Doctrine\DBAL\Schema\Column |
|
31 | 31 | */ |
32 | 32 | public function setConfig(array $config, $columnName) |
33 | 33 | { |
@@ -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 | /** |
@@ -55,7 +55,6 @@ |
||
55 | 55 | public function getSecondaryRelations(); |
56 | 56 | |
57 | 57 | /** |
58 | - * @param Model $relatedModel |
|
59 | 58 | * @return Relation |
60 | 59 | */ |
61 | 60 | public function setRelatedModel(\Illuminate\Database\Eloquent\Model $model); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Anavel\Crud\Contracts\Abstractor; |
3 | 3 | |
4 | 4 | use Anavel\Crud\Abstractor\Exceptions\RelationException; |
5 | -use Illuminate\Http\Request; |
|
6 | 5 | use Illuminate\Support\Collection; |
7 | 6 | |
8 | 7 | interface Relation |
@@ -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 | } |
@@ -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) { |