Completed
Push — master ( c4b33f...ee2ad8 )
by
unknown
05:46
created
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 2 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.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
         }
124 124
 
125 125
         $customDisplayedColumns = $this->getConfigValue($action, 'display');
126
-        $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : [];
126
+        $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: [];
127 127
 
128 128
         $columns = array();
129
-        if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
129
+        if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) {
130 130
             foreach ($customDisplayedColumns as $customColumn) {
131
-                if (! array_key_exists($customColumn, $tableColumns)) {
132
-                    throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel());
131
+                if (!array_key_exists($customColumn, $tableColumns)) {
132
+                    throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel());
133 133
                 }
134 134
 
135 135
                 $columns[$customColumn] = $tableColumns[$customColumn];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         $relations = collect();
162 162
 
163
-        if (! empty($configRelations)) {
163
+        if (!empty($configRelations)) {
164 164
             foreach ($configRelations as $relationName => $configRelation) {
165 165
                 if (is_int($relationName)) {
166 166
                     $relationName = $configRelation;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
                 $config = [];
170 170
                 if ($configRelation !== $relationName) {
171
-                    if (! is_array($configRelation)) {
171
+                    if (!is_array($configRelation)) {
172 172
                         $config['type'] = $configRelation;
173 173
                     } else {
174 174
                         $config = $configRelation;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
                 $secondaryRelations = $relation->getSecondaryRelations();
184 184
 
185 185
 
186
-                if (! $secondaryRelations->isEmpty()) {
186
+                if (!$secondaryRelations->isEmpty()) {
187 187
                     $relations->put($relationName,
188 188
                         collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations]));
189 189
                 } else {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     {
206 206
         $columns = $this->getColumns('list');
207 207
 
208
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
208
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
209 209
 
210 210
         $fields = array();
211 211
         foreach ($columns as $name => $column) {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     {
241 241
         $columns = $this->getColumns('detail');
242 242
 
243
-        $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : [];
243
+        $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: [];
244 244
 
245 245
         $fields = array();
246 246
         foreach ($columns as $name => $column) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
         $fields = array();
282 282
         foreach ($columns as $name => $column) {
283
-            if (! in_array($name, $this->getReadOnlyColumns())) {
283
+            if (!in_array($name, $this->getReadOnlyColumns())) {
284 284
                 $presentation = null;
285 285
                 if (array_key_exists($name, $this->fieldsPresentation)) {
286 286
                     $presentation = $this->fieldsPresentation[$name];
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                     ->setConfig($config)
302 302
                     ->get();
303 303
 
304
-                if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) {
304
+                if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) {
305 305
                     $field->setValue($this->instance->getAttribute($name));
306 306
                 }
307 307
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     {
342 342
         /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */
343 343
         $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager');
344
-        if (! empty($this->instance)) {
344
+        if (!empty($this->instance)) {
345 345
             $item = $this->instance;
346 346
         } else {
347 347
             $item = $modelManager->getModelInstance($this->getModel());
@@ -353,29 +353,29 @@  discard block
 block discarded – undo
353 353
             return;
354 354
         }
355 355
 
356
-        if (! empty($fields['main'])) {
356
+        if (!empty($fields['main'])) {
357 357
             foreach ($fields['main'] as $field) {
358 358
                 $requestValue = $request->input("main.{$field->getName()}");
359 359
 
360
-                if (! $field->saveIfEmpty() && empty($requestValue)) {
360
+                if (!$field->saveIfEmpty() && empty($requestValue)) {
361 361
                     continue;
362 362
                 }
363 363
 
364 364
                 if (get_class($field->getFormField()) === \FormManager\Fields\File::class) {
365 365
                     if ($request->hasFile($field->getName())) {
366
-                        $fileName = uniqid() . '.' . $request->file($field->getName())->getClientOriginalExtension();
367
-                        $modelFolder = $this->slug . DIRECTORY_SEPARATOR;
366
+                        $fileName = uniqid().'.'.$request->file($field->getName())->getClientOriginalExtension();
367
+                        $modelFolder = $this->slug.DIRECTORY_SEPARATOR;
368 368
 
369 369
                         $request->file($field->getName())->move(
370
-                            base_path(config('anavel-crud.uploads_path') . $modelFolder),
370
+                            base_path(config('anavel-crud.uploads_path').$modelFolder),
371 371
                             $fileName
372 372
                         );
373 373
 
374
-                        $requestValue = $modelFolder . $fileName;
374
+                        $requestValue = $modelFolder.$fileName;
375 375
                     }
376 376
                 }
377 377
 
378
-                if (! empty($requestValue)) {
378
+                if (!empty($requestValue)) {
379 379
                     $item->setAttribute(
380 380
                         $field->getName(),
381 381
                         $field->applyFunctions($requestValue)
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         $this->setInstance($item);
390 390
 
391 391
 
392
-        if (! empty($relations = $this->getRelations())) {
392
+        if (!empty($relations = $this->getRelations())) {
393 393
             foreach ($relations as $relationKey => $relation) {
394 394
                 if ($relation instanceof Collection) {
395 395
                     $input = $request->input($relationKey);
Please login to merge, or discard this patch.
src/Abstractor/Eloquent/Relation/Translation.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,6 @@
 block discarded – undo
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
 {
Please login to merge, or discard this 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 2 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.
src/Contracts/Abstractor/Relation.php 2 patches
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.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
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
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
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function persist(array $relationArray = null)
102 102
     {
103
-        if (! empty($relationArray)) {
103
+        if (!empty($relationArray)) {
104 104
             $keyName = $this->eloquentRelation->getParent()->getKeyName();
105 105
             $currentRelations = $this->eloquentRelation->get()->keyBy($keyName);
106 106
             $secondaryRelations = $this->getSecondaryRelations();
107 107
 
108 108
             foreach ($relationArray as $relation) {
109
-                if (! empty($relation[$keyName])
109
+                if (!empty($relation[$keyName])
110 110
                     && ($currentRelations->has($relation[$keyName]))
111 111
                 ) {
112 112
                     $relationModel = $currentRelations->get($relation[$keyName]);
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
                     $relationModel->setAttribute($fieldKey, $fieldValue);
134 134
                 }
135 135
 
136
-                if (! $shouldBeSkipped) {
136
+                if (!$shouldBeSkipped) {
137 137
                     $relationModel->save();
138 138
 
139
-                    if (! $delayedRelations->isEmpty()) {
139
+                    if (!$delayedRelations->isEmpty()) {
140 140
                         foreach ($delayedRelations as $relationKey => $delayedRelation) {
141 141
                             /** @var RelationContract $secondaryRelation */
142 142
                             $secondaryRelation = $secondaryRelations->get($relationKey);
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   +3 added lines, -3 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
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 $result->save();
50 50
             }
51 51
 
52
-            if (! $missing->isEmpty()) {
52
+            if (!$missing->isEmpty()) {
53 53
                 foreach ($missing as $result) {
54 54
                     $result->$keyName = null;
55 55
                     $result->save();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $results = $this->eloquentRelation->getResults();
84 84
 
85
-        if (! $results->isEmpty()) {
85
+        if (!$results->isEmpty()) {
86 86
             $values = [];
87 87
 
88 88
             foreach ($results as $result) {
Please login to merge, or discard this patch.