Completed
Push — master ( 41fb1c...8f9a32 )
by
unknown
05:35
created
src/Abstractor/Eloquent/Relation/MiniCrudSingle.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
111 111
                 $relationModel->setAttribute($fieldKey, $fieldValue);
112 112
             }
113 113
 
114
-            if (! $shouldBeSkipped) {
114
+            if (!$shouldBeSkipped) {
115 115
                 $relationModel->save();
116 116
             }
117 117
         }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/Translation.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Traits/ModelFields.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/SelectMultiple.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Model.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
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
         $columns = array();
134
-        if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
134
+        if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
135 135
             foreach ($customDisplayedColumns as $customColumn) {
136
-                if (! array_key_exists($customColumn, $tableColumns)) {
137
-                    throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel());
136
+                if (!array_key_exists($customColumn, $tableColumns)) {
137
+                    throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel());
138 138
                 }
139 139
 
140 140
                 $columns[$customColumn] = $tableColumns[$customColumn];
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
         $relations = collect();
167 167
 
168
-        if (! empty($configRelations)) {
168
+        if (!empty($configRelations)) {
169 169
             foreach ($configRelations as $relationName => $configRelation) {
170 170
                 if (is_int($relationName)) {
171 171
                     $relationName = $configRelation;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
                 $config = [];
175 175
                 if ($configRelation !== $relationName) {
176
-                    if (! is_array($configRelation)) {
176
+                    if (!is_array($configRelation)) {
177 177
                         $config['type'] = $configRelation;
178 178
                     } else {
179 179
                         $config = $configRelation;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 $secondaryRelations = $relation->getSecondaryRelations();
189 189
 
190 190
 
191
-                if (! $secondaryRelations->isEmpty()) {
191
+                if (!$secondaryRelations->isEmpty()) {
192 192
                     $relations->put($relationName,
193 193
                         collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations]));
194 194
                 } else {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     {
211 211
         $columns = $this->getColumns('list');
212 212
 
213
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
213
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
214 214
 
215 215
         $fields = array();
216 216
         foreach ($columns as $name => $column) {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $columns = $this->getColumns('detail');
247 247
 
248
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
248
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
249 249
 
250 250
         $fields = array();
251 251
         foreach ($columns as $name => $column) {
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 
286 286
         $fields = array();
287 287
         foreach ($columns as $name => $column) {
288
-            if (! in_array($name, $this->getReadOnlyColumns())) {
288
+            if (!in_array($name, $this->getReadOnlyColumns())) {
289 289
                 $presentation = null;
290 290
                 if (array_key_exists($name, $this->fieldsPresentation)) {
291 291
                     $presentation = $this->fieldsPresentation[$name];
@@ -306,24 +306,24 @@  discard block
 block discarded – undo
306 306
                     ->setConfig($config)
307 307
                     ->get();
308 308
 
309
-                if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) {
309
+                if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) {
310 310
                     $field->setValue($this->instance->getAttribute($name));
311 311
                 }
312 312
 
313 313
                 $fields[$arrayKey][$name] = $field;
314 314
 
315
-                if (! empty($config['form_type']) && $config['form_type'] === 'file') {
315
+                if (!empty($config['form_type']) && $config['form_type'] === 'file') {
316 316
                     $field = $this->fieldFactory
317 317
                         ->setColumn($column)
318 318
                         ->setConfig([
319
-                            'name'         => $name . '__delete',
319
+                            'name'         => $name.'__delete',
320 320
                             'presentation' => null,
321 321
                             'form_type'    => 'checkbox',
322 322
                             'no_validate'  => true,
323 323
                             'functions'    => null
324 324
                         ])
325 325
                         ->get();
326
-                    $fields[$arrayKey][$name . '__delete'] = $field;
326
+                    $fields[$arrayKey][$name.'__delete'] = $field;
327 327
                 }
328 328
             }
329 329
         }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
     {
361 361
         /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */
362 362
         $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager');
363
-        if (! empty($this->instance)) {
363
+        if (!empty($this->instance)) {
364 364
             $item = $this->instance;
365 365
         } else {
366 366
             $item = $modelManager->getModelInstance($this->getModel());
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
             return;
373 373
         }
374 374
 
375
-        if (! empty($fields['main'])) {
375
+        if (!empty($fields['main'])) {
376 376
             $skip = null;
377 377
             foreach ($fields['main'] as $key => $field) {
378 378
                 /** @var FieldContract $field */
@@ -395,20 +395,20 @@  discard block
 block discarded – undo
395 395
 
396 396
                 if (get_class($field->getFormField()) === \FormManager\Fields\File::class) {
397 397
                     $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName);
398
-                    if (! empty($handleResult['skip'])) {
398
+                    if (!empty($handleResult['skip'])) {
399 399
                         $skip = $handleResult['skip'];
400 400
                     }
401
-                    if (! empty($handleResult['requestValue'])) {
401
+                    if (!empty($handleResult['requestValue'])) {
402 402
                         $requestValue = $handleResult['requestValue'];
403 403
                     }
404 404
                 }
405 405
 
406 406
 
407
-                if (! $field->saveIfEmpty() && empty($requestValue)) {
407
+                if (!$field->saveIfEmpty() && empty($requestValue)) {
408 408
                     continue;
409 409
                 }
410 410
 
411
-                if (! empty($requestValue)) {
411
+                if (!empty($requestValue)) {
412 412
                     $item->setAttribute(
413 413
                         $fieldName,
414 414
                         $field->applyFunctions($requestValue)
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
         $this->setInstance($item);
423 423
 
424 424
 
425
-        if (! empty($relations = $this->getRelations())) {
425
+        if (!empty($relations = $this->getRelations())) {
426 426
             foreach ($relations as $relationKey => $relation) {
427 427
                 if ($relation instanceof Collection) {
428 428
                     $input = $request->input($relationKey);
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/MiniCrud.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
                 $config = [
124 124
                     'name' => $columnName,
125
-                    'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)),
125
+                    'presentation' => $this->name.' '.ucfirst(transcrud($columnName)),
126 126
                     'form_type' => $formType,
127 127
                     'no_validate' => true,
128 128
                     'validation' => null,
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                     $field = $this->fieldFactory
144 144
                         ->setColumn($column)
145 145
                         ->setConfig([
146
-                            'name' => $columnName . '__delete',
146
+                            'name' => $columnName.'__delete',
147 147
                             'presentation' => null,
148 148
                             'form_type' => 'checkbox',
149 149
                             'no_validate' => true,
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                             'functions' => null
152 152
                         ])
153 153
                         ->get();
154
-                    $fields[$columnName . '__delete'] = $field;
154
+                    $fields[$columnName.'__delete'] = $field;
155 155
                 }
156 156
             }
157 157
         }
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
                     $fieldName = $field->getName();
196 196
 
197 197
                     if (get_class($field->getFormField()) === \FormManager\Fields\File::class) {
198
-                        $handleResult = $this->handleField($request, $relationModel, $fieldsBase, $this->name . ".$relationIndex", $fieldName);
199
-                        if (! empty($handleResult['skip'])) {
198
+                        $handleResult = $this->handleField($request, $relationModel, $fieldsBase, $this->name.".$relationIndex", $fieldName);
199
+                        if (!empty($handleResult['skip'])) {
200 200
                             $skip = $handleResult['skip'];
201 201
                             unset($relationArray[$relationIndex][$skip]);
202 202
                         }
203
-                        if (! empty($handleResult['requestValue'])) {
203
+                        if (!empty($handleResult['requestValue'])) {
204 204
                             $relationArray[$relationIndex][$fieldName] = $handleResult['requestValue'];
205 205
                         }
206 206
                     }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Traits/HandleFiles.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
 {
12 12
     protected function handleField(Request $request, $item, array $fields, $groupName, $fieldName)
13 13
     {
14
-        $modelFolder = $this->slug . DIRECTORY_SEPARATOR;
15
-        $basePath = base_path(DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR .config('anavel-crud.uploads_path'));
16
-        $modelPath = $basePath . $modelFolder;
14
+        $modelFolder = $this->slug.DIRECTORY_SEPARATOR;
15
+        $basePath = base_path(DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.config('anavel-crud.uploads_path'));
16
+        $modelPath = $basePath.$modelFolder;
17 17
         $skip = null;
18 18
         $requestValue = null;
19
-        if (! empty($fields["{$fieldName}__delete"])) {
19
+        if (!empty($fields["{$fieldName}__delete"])) {
20 20
             //We never want to save this field, it doesn't exist in the DB
21 21
             $skip = "{$fieldName}__delete";
22 22
 
23 23
 
24 24
             //If user wants to delete the existing file
25
-            if (! empty($request->input("{$groupName}.{$fieldName}__delete"))) {
25
+            if (!empty($request->input("{$groupName}.{$fieldName}__delete"))) {
26 26
                 $adapter = new Local($basePath);
27 27
                 $filesystem = new Filesystem($adapter);
28 28
                 if ($filesystem->has($item->$fieldName)) {
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
                 ];
40 40
             }
41 41
         }
42
-        if ($request->hasFile($groupName .'.'.$fieldName)) {
43
-            $fileName = uniqid() . '.' . $request->file($groupName .'.'.$fieldName)->getClientOriginalExtension();
42
+        if ($request->hasFile($groupName.'.'.$fieldName)) {
43
+            $fileName = uniqid().'.'.$request->file($groupName.'.'.$fieldName)->getClientOriginalExtension();
44 44
 
45 45
 
46
-            $request->file($groupName .'.'.$fieldName)->move(
46
+            $request->file($groupName.'.'.$fieldName)->move(
47 47
                 $modelPath,
48 48
                 $fileName
49 49
             );
50 50
 
51
-            $requestValue = $modelFolder . $fileName;
52
-        } elseif (! empty($request->file($groupName .'.'.$fieldName)) && ! $request->file($groupName .'.'.$fieldName)->isValid()) {
53
-            throw new \Exception($request->file($groupName .'.'.$fieldName)->getErrorMessage());
51
+            $requestValue = $modelFolder.$fileName;
52
+        } elseif (!empty($request->file($groupName.'.'.$fieldName)) && !$request->file($groupName.'.'.$fieldName)->isValid()) {
53
+            throw new \Exception($request->file($groupName.'.'.$fieldName)->getErrorMessage());
54 54
         }
55 55
 
56 56
         return [
Please login to merge, or discard this patch.