Passed
Push — 1.2 ( 9a87a2...01151e )
by Quentin
10:35 queued 05:14
created
src/Repositories/Behaviors/HandleRepeaters.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
         $relationRepository = $this->getModelRepository($relation, $model);
16 16
 
17 17
         if (!$keepExisting) {
18
-            $object->$relation()->each(function ($repeaterElement) {
18
+            $object->$relation()->each(function($repeaterElement) {
19 19
                 $repeaterElement->forceDelete();
20 20
             });
21 21
         }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 
113 113
             if (isset($relatedItemFormFields['medias'])) {
114 114
                 if (config('twill.media_library.translated_form_fields', false)) {
115
-                    Collection::make($relatedItemFormFields['medias'])->each(function ($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) {
116
-                        $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function ($medias, $role) use ($locale, $relation, $relationItem) {
115
+                    Collection::make($relatedItemFormFields['medias'])->each(function($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) {
116
+                        $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function($medias, $role) use ($locale, $relation, $relationItem) {
117 117
                             return [
118 118
                                 "blocks[$relation-$relationItem->id][$role][$locale]" => $medias,
119 119
                             ];
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
             }
128 128
 
129 129
             if (isset($relatedItemFormFields['files'])) {
130
-                Collection::make($relatedItemFormFields['files'])->each(function ($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) {
131
-                    $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $relation, $relationItem) {
130
+                Collection::make($relatedItemFormFields['files'])->each(function($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) {
131
+                    $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $relation, $relationItem) {
132 132
                         return [
133 133
                             "blocks[$relation-$relationItem->id][$role][$locale]" => $files,
134 134
                         ];
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleTranslations.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 
24 24
             $submittedLanguages = Collection::make($fields['languages'] ?? []);
25 25
 
26
-            $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) {
26
+            $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) {
27 27
                 return $language['published'];
28 28
             });
29 29
 
30 30
             foreach ($locales as $index => $locale) {
31
-                $submittedLanguage = Arr::first($submittedLanguages->filter(function ($lang) use ($locale) {
31
+                $submittedLanguage = Arr::first($submittedLanguages->filter(function($lang) use ($locale) {
32 32
                     return $lang['value'] == $locale;
33 33
                 }));
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
                 $fields[$locale] = [
40 40
                     'active' => $activeField,
41
-                ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) {
41
+                ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) {
42 42
                     $attributeValue = $fields[$attribute] ?? null;
43 43
 
44 44
                     // if we are at the last locale,
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         if (property_exists($this->model, 'translatedAttributes')) {
81 81
             $attributes = $this->model->translatedAttributes;
82
-            $query->whereHas('translations', function ($q) use ($scopes, $attributes) {
82
+            $query->whereHas('translations', function($q) use ($scopes, $attributes) {
83 83
                 foreach ($attributes as $attribute) {
84 84
                     if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) {
85 85
                         $q->where($attribute, 'like', '%' . $scopes[$attribute] . '%');
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleMedias.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $mediasCollection = Collection::make();
24 24
         $mediasFromFields = $this->getMedias($fields);
25 25
 
26
-        $mediasFromFields->each(function ($media) use ($object, $mediasCollection) {
26
+        $mediasFromFields->each(function($media) use ($object, $mediasCollection) {
27 27
             $newMedia = Media::withTrashed()->find(is_array($media['id']) ? Arr::first($media['id']) : $media['id']);
28 28
             $pivot = $newMedia->newPivot($object, Arr::except($media, ['id']), 'mediables', true);
29 29
             $newMedia->setRelation('pivot', $pivot);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         $object->medias()->sync([]);
50 50
 
51
-        $this->getMedias($fields)->each(function ($media) use ($object) {
51
+        $this->getMedias($fields)->each(function($media) use ($object) {
52 52
             $object->medias()->attach($media['id'], Arr::except($media, ['id']));
53 53
         });
54 54
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                 if (in_array($role, array_keys($this->model->mediasParams ?? []))
78 78
                     || in_array($role, array_keys(config('twill.block_editor.crops', [])))
79 79
                     || in_array($role, array_keys(config('twill.settings.crops', [])))) {
80
-                    Collection::make($mediasForRole)->each(function ($media) use (&$medias, $role, $locale) {
80
+                    Collection::make($mediasForRole)->each(function($media) use (&$medias, $role, $locale) {
81 81
                         $customMetadatas = $media['metadatas']['custom'] ?? [];
82 82
                         if (isset($media['crops']) && !empty($media['crops'])) {
83 83
                             foreach ($media['crops'] as $cropName => $cropData) {
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleSlugs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
         }
79 79
 
80 80
         if (!$item && config('translatable.use_property_fallback', false)) {
81
-            $item = (clone $query)->orWhere(function ($query) {
81
+            $item = (clone $query)->orWhere(function($query) {
82 82
                 return $query->withActiveTranslations(config('translatable.fallback_locale'));
83 83
             })->forFallbackLocaleSlug($slug)->first();
84 84
 
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleFiles.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $filesCollection = Collection::make();
24 24
         $filesFromFields = $this->getFiles($fields);
25 25
 
26
-        $filesFromFields->each(function ($file) use ($object, $filesCollection) {
26
+        $filesFromFields->each(function($file) use ($object, $filesCollection) {
27 27
             $newFile = File::withTrashed()->find($file['id']);
28 28
             $pivot = $newFile->newPivot($object, Arr::except($file, ['id']), 'fileables', true);
29 29
             $newFile->setRelation('pivot', $pivot);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         $object->files()->sync([]);
50 50
 
51
-        $this->getFiles($fields)->each(function ($file) use ($object) {
51
+        $this->getFiles($fields)->each(function($file) use ($object) {
52 52
             $object->files()->attach($file['id'], Arr::except($file, ['id']));
53 53
         });
54 54
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 if (in_array($role, $this->model->filesParams ?? [])
75 75
                     || in_array($role, config('twill.block_editor.files', []))) {
76 76
 
77
-                    Collection::make($filesForRole)->each(function ($file) use (&$files, $role, $locale) {
77
+                    Collection::make($filesForRole)->each(function($file) use (&$files, $role, $locale) {
78 78
                         $files->push([
79 79
                             'id' => $file['id'],
80 80
                             'role' => $role,
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         if ($object->has('files')) {
100 100
             foreach ($object->files->groupBy('pivot.role') as $role => $filesByRole) {
101 101
                 foreach ($filesByRole->groupBy('pivot.locale') as $locale => $filesByLocale) {
102
-                    $fields['files'][$locale][$role] = $filesByLocale->map(function ($file) {
102
+                    $fields['files'][$locale][$role] = $filesByLocale->map(function($file) {
103 103
                         return $file->toCmsArray();
104 104
                     });
105 105
                 }
Please login to merge, or discard this patch.
src/Repositories/ModuleRepository.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
         foreach ($fields as $field) {
180 180
             if (in_array($field, $translatedAttributes)) {
181
-                $query->orWhereHas('translations', function ($q) use ($field, $search) {
181
+                $query->orWhereHas('translations', function($q) use ($field, $search) {
182 182
                     $q->where($field, $this->getLikeOperator(), "%{$search}%");
183 183
                 });
184 184
             } else {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function create($fields)
207 207
     {
208
-        return DB::transaction(function () use ($fields) {
208
+        return DB::transaction(function() use ($fields) {
209 209
             $original_fields = $fields;
210 210
 
211 211
             $fields = $this->prepareFieldsBeforeCreate($fields);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function update($id, $fields)
262 262
     {
263
-        DB::transaction(function () use ($id, $fields) {
263
+        DB::transaction(function() use ($id, $fields) {
264 264
             $object = $this->model->findOrFail($id);
265 265
 
266 266
             $this->beforeSave($object, $fields);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function updateBasic($id, $values, $scopes = [])
285 285
     {
286
-        return DB::transaction(function () use ($id, $values, $scopes) {
286
+        return DB::transaction(function() use ($id, $values, $scopes) {
287 287
             // apply scopes if no id provided
288 288
             if (is_null($id)) {
289 289
                 $query = $this->model->query();
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
                 $query->update($values);
296 296
 
297
-                $query->get()->each(function ($object) use ($values) {
297
+                $query->get()->each(function($object) use ($values) {
298 298
                     $this->afterUpdateBasic($object, $values);
299 299
                 });
300 300
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                 $query = $this->model->whereIn('id', $id);
307 307
                 $query->update($values);
308 308
 
309
-                $query->get()->each(function ($object) use ($values) {
309
+                $query->get()->each(function($object) use ($values) {
310 310
                     $this->afterUpdateBasic($object, $values);
311 311
                 });
312 312
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      */
330 330
     public function setNewOrder($ids)
331 331
     {
332
-        DB::transaction(function () use ($ids) {
332
+        DB::transaction(function() use ($ids) {
333 333
             $this->model->setNewOrder($ids);
334 334
         }, 3);
335 335
     }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
      */
341 341
     public function delete($id)
342 342
     {
343
-        return DB::transaction(function () use ($id) {
343
+        return DB::transaction(function() use ($id) {
344 344
             if (($object = $this->model->find($id)) === null) {
345 345
                 return false;
346 346
             }
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
      */
361 361
     public function bulkDelete($ids)
362 362
     {
363
-        return DB::transaction(function () use ($ids) {
363
+        return DB::transaction(function() use ($ids) {
364 364
             try {
365
-                Collection::make($ids)->each(function ($id) {
365
+                Collection::make($ids)->each(function($id) {
366 366
                     $this->delete($id);
367 367
                 });
368 368
             } catch (\Exception $e) {
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function restore($id)
382 382
     {
383
-        return DB::transaction(function () use ($id) {
383
+        return DB::transaction(function() use ($id) {
384 384
             if (($object = $this->model->withTrashed()->find($id)) != null) {
385 385
                 $object->restore();
386 386
                 $this->afterRestore($object);
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public function bulkRestore($ids)
399 399
     {
400
-        return DB::transaction(function () use ($ids) {
400
+        return DB::transaction(function() use ($ids) {
401 401
             try {
402 402
                 $query = $this->model->withTrashed()->whereIn('id', $ids);
403 403
                 $objects = $query->get();
404 404
 
405 405
                 $query->restore();
406 406
 
407
-                $objects->each(function ($object) {
407
+                $objects->each(function($object) {
408 408
                     $this->afterRestore($object);
409 409
                 });
410 410
             } catch (\Exception $e) {
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
      */
665 665
     public function getFormFieldsForBrowser($object, $relation, $routePrefix = null, $titleKey = 'title', $moduleName = null)
666 666
     {
667
-        return $object->$relation->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) {
667
+        return $object->$relation->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) {
668 668
             return [
669 669
                 'id' => $relatedElement->id,
670 670
                 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey,
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
      */
684 684
     public function getFormFieldsForRelatedBrowser($object, $relation)
685 685
     {
686
-        return $object->getRelated($relation)->map(function ($relatedElement) {
686
+        return $object->getRelated($relation)->map(function($relatedElement) {
687 687
             return ($relatedElement != null) ? [
688 688
                 'id' => $relatedElement->id,
689 689
                 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title,
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
             ]) + (classHasTrait($relatedElement, HasMedias::class) ? [
694 694
                 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]),
695 695
             ] : []) : [];
696
-        })->reject(function ($item) {
696
+        })->reject(function($item) {
697 697
             return empty($item);
698 698
         })->values()->toArray();
699 699
     }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
     {
789 789
         if (isset($scopes[$scopeField])) {
790 790
             $id = $scopes[$scopeField];
791
-            $query->whereHas($scopeRelation, function ($query) use ($id, $scopeField) {
791
+            $query->whereHas($scopeRelation, function($query) use ($id, $scopeField) {
792 792
                 $query->where($scopeField, $id);
793 793
             });
794 794
             unset($scopes[$scopeField]);
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     {
820 820
 
821 821
         if (isset($scopes[$scopeField]) && is_string($scopes[$scopeField])) {
822
-            $query->where(function ($query) use (&$scopes, $scopeField, $orFields) {
822
+            $query->where(function($query) use (&$scopes, $scopeField, $orFields) {
823 823
                 foreach ($orFields as $field) {
824 824
                     $query->orWhere($field, $this->getLikeOperator(), '%' . $scopes[$scopeField] . '%');
825 825
                     unset($scopes[$field]);
Please login to merge, or discard this patch.
migrations/change_locale_column_in_twill_fileables.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     public function up()
9 9
     {
10 10
         if (Schema::hasTable('fileables') && Schema::hasColumn('fileables', 'locale')) {
11
-            Schema::table('fileables', function (Blueprint $table) {
11
+            Schema::table('fileables', function(Blueprint $table) {
12 12
                 $table->string('locale', 7)->change();
13 13
             });
14 14
         }
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public function down()
18 18
     {
19 19
         if (Schema::hasTable('fileables') && Schema::hasColumn('fileables', 'locale')) {
20
-            Schema::table('fileables', function (Blueprint $table) {
20
+            Schema::table('fileables', function(Blueprint $table) {
21 21
                 $table->string('locale', 6)->change();
22 22
             });
23 23
         }
Please login to merge, or discard this patch.
migrations/create_related_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('related', function (Blueprint $table) {
16
+        Schema::create('related', function(Blueprint $table) {
17 17
             $table->integer('subject_id')->nullable()->unsigned();
18 18
             $table->string('subject_type', 255);
19 19
             $table->integer('related_id')->nullable()->unsigned();
Please login to merge, or discard this patch.
migrations/create_twill_users_tables.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         $twillUsersTable = config('twill.users_table', 'twill_users');
17 17
 
18 18
         if (!Schema::hasTable($twillUsersTable)) {
19
-            Schema::create($twillUsersTable, function (Blueprint $table) {
19
+            Schema::create($twillUsersTable, function(Blueprint $table) {
20 20
                 createDefaultTableFields($table);
21 21
                 $table->string('name');
22 22
                 $table->string('email')->unique();
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $twillPasswordResetsTable = config('twill.password_resets_table', 'twill_password_resets');
32 32
 
33 33
         if (!Schema::hasTable($twillPasswordResetsTable)) {
34
-            Schema::create($twillPasswordResetsTable, function (Blueprint $table) {
34
+            Schema::create($twillPasswordResetsTable, function(Blueprint $table) {
35 35
                 $table->string('email')->index();
36 36
                 $table->string('token')->index();
37 37
                 $table->timestamp('created_at')->nullable();
Please login to merge, or discard this patch.