Completed
Push — master ( eecd8e...8b8777 )
by Adrian
05:13
created
src/Abstractor/Eloquent/Model.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
         }
137 137
 
138 138
         $customDisplayedColumns = $this->getConfigValue($action, 'display');
139
-        $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : [];
139
+        $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: [];
140 140
 
141 141
         $columns = array();
142
-        if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
142
+        if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
143 143
             foreach ($customDisplayedColumns as $customColumn) {
144 144
                 if (strpos($customColumn, '.')) {
145 145
                     $customColumnRelation = explode('.', $customColumn);
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 
155 155
                     $relationColumns = $nestedRelation->getModelAbstractor()->getColumns($action);
156 156
 
157
-                    if (! array_key_exists($customColumnRelationFieldName, $relationColumns)) {
158
-                        throw new AbstractorException("Column " . $customColumnRelationFieldName . " does not exist on relation " . implode('.', $customColumnRelation) . " of model " . $this->getModel());
157
+                    if (!array_key_exists($customColumnRelationFieldName, $relationColumns)) {
158
+                        throw new AbstractorException("Column ".$customColumnRelationFieldName." does not exist on relation ".implode('.', $customColumnRelation)." of model ".$this->getModel());
159 159
                     }
160 160
 
161 161
                     $columns[$customColumn] = $relationColumns[$customColumnRelationFieldName];
162 162
                 } else {
163
-                    if (! array_key_exists($customColumn, $tableColumns)) {
164
-                        throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel());
163
+                    if (!array_key_exists($customColumn, $tableColumns)) {
164
+                        throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel());
165 165
                     }
166 166
 
167 167
                     $columns[$customColumn] = $tableColumns[$customColumn];
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
     {
189 189
         $relations = $modelAbstractor->getRelations();
190 190
 
191
-        if (! $relations->has($relationName)) {
192
-            throw new AbstractorException("Relation " . $relationName . " not configured on " . $modelAbstractor->getModel());
191
+        if (!$relations->has($relationName)) {
192
+            throw new AbstractorException("Relation ".$relationName." not configured on ".$modelAbstractor->getModel());
193 193
         }
194 194
 
195 195
         $relation = $relations->get($relationName);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
         $relations = collect();
212 212
 
213
-        if (! empty($configRelations)) {
213
+        if (!empty($configRelations)) {
214 214
             foreach ($configRelations as $relationName => $configRelation) {
215 215
                 if (is_int($relationName)) {
216 216
                     $relationName = $configRelation;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
                 $config = [];
220 220
                 if ($configRelation !== $relationName) {
221
-                    if (! is_array($configRelation)) {
221
+                    if (!is_array($configRelation)) {
222 222
                         $config['type'] = $configRelation;
223 223
                     } else {
224 224
                         $config = $configRelation;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 $secondaryRelations = $relation->getSecondaryRelations();
234 234
 
235 235
 
236
-                if (! $secondaryRelations->isEmpty()) {
236
+                if (!$secondaryRelations->isEmpty()) {
237 237
                     $relations->put(
238 238
                         $relationName,
239 239
                         collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations])
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     {
257 257
         $columns = $this->getColumns('list');
258 258
 
259
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
259
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
260 260
 
261 261
         $fields = array();
262 262
         foreach ($columns as $name => $column) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     {
292 292
         $columns = $this->getColumns('detail');
293 293
 
294
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
294
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
295 295
 
296 296
         $fields = array();
297 297
         foreach ($columns as $name => $column) {
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
         $fields = array();
333 333
         foreach ($columns as $name => $column) {
334
-            if (! in_array($name, $this->getReadOnlyColumns())) {
334
+            if (!in_array($name, $this->getReadOnlyColumns())) {
335 335
                 $presentation = null;
336 336
                 if (array_key_exists($name, $this->fieldsPresentation)) {
337 337
                     $presentation = $this->fieldsPresentation[$name];
@@ -352,24 +352,24 @@  discard block
 block discarded – undo
352 352
                     ->setConfig($config)
353 353
                     ->get();
354 354
 
355
-                if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) {
355
+                if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) {
356 356
                     $field->setValue($this->instance->getAttribute($name));
357 357
                 }
358 358
 
359 359
                 $fields[$arrayKey][$name] = $field;
360 360
 
361
-                if (! empty($config['form_type']) && $config['form_type'] === 'file') {
361
+                if (!empty($config['form_type']) && $config['form_type'] === 'file') {
362 362
                     $field = $this->fieldFactory
363 363
                         ->setColumn($column)
364 364
                         ->setConfig([
365
-                            'name'         => $name . '__delete',
365
+                            'name'         => $name.'__delete',
366 366
                             'presentation' => null,
367 367
                             'form_type'    => 'checkbox',
368 368
                             'no_validate'  => true,
369 369
                             'functions'    => null
370 370
                         ])
371 371
                         ->get();
372
-                    $fields[$arrayKey][$name . '__delete'] = $field;
372
+                    $fields[$arrayKey][$name.'__delete'] = $field;
373 373
                 }
374 374
             }
375 375
         }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     {
407 407
         /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */
408 408
         $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager');
409
-        if (! empty($this->instance)) {
409
+        if (!empty($this->instance)) {
410 410
             $item = $this->instance;
411 411
         } else {
412 412
             $item = $modelManager->getModelInstance($this->getModel());
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
             return;
419 419
         }
420 420
 
421
-        if (! empty($fields['main'])) {
421
+        if (!empty($fields['main'])) {
422 422
             $skip = null;
423 423
             foreach ($fields['main'] as $key => $field) {
424 424
                 /** @var FieldContract $field */
@@ -443,20 +443,20 @@  discard block
 block discarded – undo
443 443
 
444 444
                 if (get_class($field->getFormField()) === \FormManager\Fields\File::class) {
445 445
                     $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName);
446
-                    if (! empty($handleResult['skip'])) {
446
+                    if (!empty($handleResult['skip'])) {
447 447
                         $skip = $handleResult['skip'];
448 448
                     }
449
-                    if (! empty($handleResult['requestValue'])) {
449
+                    if (!empty($handleResult['requestValue'])) {
450 450
                         $requestValue = $handleResult['requestValue'];
451 451
                     }
452 452
                 }
453 453
 
454 454
 
455
-                if (! $field->saveIfEmpty() && empty($requestValue)) {
455
+                if (!$field->saveIfEmpty() && empty($requestValue)) {
456 456
                     continue;
457 457
                 }
458 458
 
459
-                if (! empty($requestValue) || (empty($requestValue) && ! empty($item->getAttribute($fieldName)))) {
459
+                if (!empty($requestValue) || (empty($requestValue) && !empty($item->getAttribute($fieldName)))) {
460 460
                     $item->setAttribute(
461 461
                         $fieldName,
462 462
                         $field->applyFunctions($requestValue)
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
         $this->setInstance($item);
471 471
 
472 472
 
473
-        if (! empty($relations = $this->getRelations())) {
473
+        if (!empty($relations = $this->getRelations())) {
474 474
             foreach ($relations as $relationKey => $relation) {
475 475
                 if ($relation instanceof Collection) {
476 476
                     $input = $request->input($relationKey);
Please login to merge, or discard this patch.