Completed
Push — master ( 08f3b7...ac4669 )
by Adrian
05:56
created
src/Abstractor/Eloquent/Model.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -128,32 +128,32 @@  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
         $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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.