Completed
Push — master ( 737f06...12c136 )
by
unknown
06:05
created
src/CrudModuleProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
 
48 48
         $this->app->bind(
49 49
             'Anavel\Crud\Contracts\Abstractor\FieldFactory',
50
-            function () {
50
+            function() {
51 51
                 return new FieldAbstractorFactory(new FormFactory);
52 52
             }
53 53
         );
54 54
 
55 55
         $this->app->bind(
56 56
             'Anavel\Crud\Contracts\Abstractor\RelationFactory',
57
-            function () {
57
+            function() {
58 58
                 return new RelationAbstractorFactory(
59 59
                     $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'],
60 60
                     $this->app['Anavel\Crud\Contracts\Abstractor\FieldFactory']
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
         $this->app->bind(
66 66
             'Anavel\Crud\Contracts\Abstractor\ModelFactory',
67
-            function () {
67
+            function() {
68 68
                 return new ModelAbstractorFactory(
69 69
                     config('anavel-crud.models'),
70 70
                     $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'],
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         $this->app->bind(
79 79
             'Anavel\Crud\Contracts\Form\Generator',
80
-            function () {
80
+            function() {
81 81
                 return new FormGenerator(new FormFactory);
82 82
             }
83 83
         );
Please login to merge, or discard this patch.
src/Http/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
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'
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Model.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,6 +85,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,6 @@
 block discarded – undo
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
 {
Please login to merge, or discard this 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/Traits/ModelFields.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this 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.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,6 @@
 block discarded – undo
4 4
 namespace Anavel\Crud\Abstractor\Eloquent\Traits;
5 5
 
6 6
 
7
-use Anavel\Crud\Contracts\Abstractor\Field;
8
-
9 7
 trait ModelFields
10 8
 {
11 9
     protected $fieldsPresentation = [];
Please login to merge, or discard this patch.
src/Contracts/Abstractor/Relation.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,6 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
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/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/Traits/HandleFiles.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -9,6 +9,9 @@
 block discarded – undo
9 9
 
10 10
 trait HandleFiles
11 11
 {
12
+    /**
13
+     * @param string $groupName
14
+     */
12 15
     protected function handleField(Request $request, $item, array $fields, $currentKey,  $groupName, $fieldName)
13 16
     {
14 17
         $modelFolder = $this->slug . DIRECTORY_SEPARATOR;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 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;
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
         $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
                 dd($item);
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
                 ];
41 41
             }
42 42
         }
43
-        if ($request->hasFile($groupName .'.'.$fieldName)) {
44
-            $fileName = uniqid() . '.' . $request->file($groupName .'.'.$fieldName)->getClientOriginalExtension();
43
+        if ($request->hasFile($groupName.'.'.$fieldName)) {
44
+            $fileName = uniqid().'.'.$request->file($groupName.'.'.$fieldName)->getClientOriginalExtension();
45 45
 
46 46
 
47
-            $request->file($groupName .'.'.$fieldName)->move(
47
+            $request->file($groupName.'.'.$fieldName)->move(
48 48
                 $modelPath,
49 49
                 $fileName
50 50
             );
51 51
 
52
-            $requestValue = $modelFolder . $fileName;
53
-        } elseif (! empty($request->file($groupName .'.'.$fieldName)) && ! $request->file($groupName .'.'.$fieldName)->isValid()) {
54
-            throw new \Exception($request->file($groupName .'.'.$fieldName)->getErrorMessage());
52
+            $requestValue = $modelFolder.$fileName;
53
+        } elseif (!empty($request->file($groupName.'.'.$fieldName)) && !$request->file($groupName.'.'.$fieldName)->isValid()) {
54
+            throw new \Exception($request->file($groupName.'.'.$fieldName)->getErrorMessage());
55 55
         }
56 56
 
57 57
         return [
Please login to merge, or discard this patch.