Passed
Pull Request — 3.x (#1388)
by Harings
15:34
created
src/Repositories/SettingRepository.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function byKey($key, $section = null)
36 36
     {
37
-        $settingQuery = $this->model->when($section, function ($query) use ($section) {
37
+        $settingQuery = $this->model->when($section, function($query) use ($section) {
38 38
             $query->where('section', $section);
39 39
         })->where('key', $key);
40 40
 
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function getFormFields($section = null)
53 53
     {
54
-        $settings = $this->model->when($section, function ($query) use ($section) {
54
+        $settings = $this->model->when($section, function($query) use ($section) {
55 55
             $query->where('section', $section);
56 56
         })->with('translations', 'medias')->get();
57 57
 
58 58
 
59 59
         if (config('twill.media_library.translated_form_fields', false)) {
60
-            $medias = $settings->reduce(function ($carry, $setting) {
60
+            $medias = $settings->reduce(function($carry, $setting) {
61 61
                 foreach (getLocales() as $locale) {
62 62
                     if (!empty(parent::getFormFields($setting)['medias'][$locale]) && !empty(parent::getFormFields($setting)['medias'][$locale][$setting->key]))
63 63
                     {
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
                 return $carry;
68 68
             });
69 69
         } else {
70
-            $medias = $settings->mapWithKeys(function ($setting) {
70
+            $medias = $settings->mapWithKeys(function($setting) {
71 71
                 return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null];
72 72
             })->filter()->toArray();
73 73
         }
74 74
 
75
-        return $settings->mapWithKeys(function ($setting) {
75
+        return $settings->mapWithKeys(function($setting) {
76 76
             $settingValue = [];
77 77
 
78 78
             foreach ($setting->translations as $translation) {
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 
124 124
             if (config('twill.media_library.translated_form_fields', false)) {
125 125
                 foreach (getLocales() as $locale) {
126
-                    $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function ($media) {
126
+                    $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function($media) {
127 127
                         return json_decode($media, true);
128 128
                     })->filter()->toArray();
129 129
                 }
130 130
             } else {
131
-                $medias =  [
132
-                    $role => Collection::make($settingsFields['medias'][$role])->map(function ($media) {
131
+                $medias = [
132
+                    $role => Collection::make($settingsFields['medias'][$role])->map(function($media) {
133 133
                         return json_decode($media, true);
134 134
                     })->values()->filter()->toArray(),
135 135
                 ];
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
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 
33 33
             $submittedLanguages = Collection::make($fields['languages'] ?? []);
34 34
 
35
-            $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) {
35
+            $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) {
36 36
                 return $language['published'];
37 37
             });
38 38
 
39 39
             foreach ($locales as $index => $locale) {
40
-                $submittedLanguage = Arr::first($submittedLanguages->filter(function ($lang) use ($locale) {
40
+                $submittedLanguage = Arr::first($submittedLanguages->filter(function($lang) use ($locale) {
41 41
                     return $lang['value'] == $locale;
42 42
                 }));
43 43
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
                 $fields[$locale] = [
49 49
                     'active' => $activeField,
50
-                ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) {
50
+                ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) {
51 51
                     $attributeValue = $fields[$attribute] ?? null;
52 52
 
53 53
                     // if we are at the last locale,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     {
107 107
         if ($this->model->isTranslatable()) {
108 108
             $attributes = $this->model->translatedAttributes;
109
-            $query->whereHas('translations', function ($q) use ($scopes, $attributes) {
109
+            $query->whereHas('translations', function($q) use ($scopes, $attributes) {
110 110
                 foreach ($attributes as $attribute) {
111 111
                     if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) {
112 112
                         $q->where($attribute, $this->getLikeOperator(), '%' . $scopes[$attribute] . '%');
Please login to merge, or discard this patch.
src/Http/ViewComposers/FilesUploaderConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,13 +51,13 @@
 block discarded – undo
51 51
         // anonymous functions are used to let configuration dictate
52 52
         // the execution of the appropriate implementation
53 53
         $endpointByType = [
54
-            'local' => function () {
54
+            'local' => function() {
55 55
                 return $this->urlGenerator->route('twill.file-library.files.store');
56 56
             },
57
-            's3' => function () use ($libraryDisk) {
57
+            's3' => function() use ($libraryDisk) {
58 58
                 return s3Endpoint($libraryDisk);
59 59
             },
60
-            'azure' => function () use ($libraryDisk) {
60
+            'azure' => function() use ($libraryDisk) {
61 61
                 return azureEndpoint($libraryDisk);
62 62
             },
63 63
         ];
Please login to merge, or discard this patch.
src/Http/ViewComposers/MediasUploaderConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,13 +51,13 @@
 block discarded – undo
51 51
         // anonymous functions are used to let configuration dictate
52 52
         // the execution of the appropriate implementation
53 53
         $endpointByType = [
54
-            'local' => function () {
54
+            'local' => function() {
55 55
                 return $this->urlGenerator->route('twill.media-library.medias.store');
56 56
             },
57
-            's3' => function () use ($libraryDisk) {
57
+            's3' => function() use ($libraryDisk) {
58 58
                 return s3Endpoint($libraryDisk);
59 59
             },
60
-            'azure' => function () use ($libraryDisk) {
60
+            'azure' => function() use ($libraryDisk) {
61 61
                 return azureEndpoint($libraryDisk);
62 62
             },
63 63
         ];
Please login to merge, or discard this patch.
src/TwillServiceProvider.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
         }
142 142
 
143 143
         if (config('twill.enabled.media-library')) {
144
-            $this->app->singleton('imageService', function () {
144
+            $this->app->singleton('imageService', function() {
145 145
                 return $this->app->make(config('twill.media_library.image_service'));
146 146
             });
147 147
         }
148 148
 
149 149
         if (config('twill.enabled.file-library')) {
150
-            $this->app->singleton('fileService', function () {
150
+            $this->app->singleton('fileService', function() {
151 151
                 return $this->app->make(config('twill.file_library.file_service'));
152 152
             });
153 153
         }
@@ -360,20 +360,20 @@  discard block
 block discarded – undo
360 360
     {
361 361
         $blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler();
362 362
 
363
-        $blade->directive('dd', function ($param) {
363
+        $blade->directive('dd', function($param) {
364 364
             return "<?php dd({$param}); ?>";
365 365
         });
366 366
 
367
-        $blade->directive('dumpData', function ($data) {
367
+        $blade->directive('dumpData', function($data) {
368 368
             return sprintf("<?php (new Symfony\Component\VarDumper\VarDumper)->dump(%s); exit; ?>",
369 369
                 null != $data ? $data : "get_defined_vars()");
370 370
         });
371 371
 
372
-        $blade->directive('formField', function ($expression) {
372
+        $blade->directive('formField', function($expression) {
373 373
             return $this->includeView('partials.form._', $expression);
374 374
         });
375 375
 
376
-        $blade->directive('partialView', function ($expression) {
376
+        $blade->directive('partialView', function($expression) {
377 377
 
378 378
             $expressionAsArray = str_getcsv($expression, ',', '\'');
379 379
 
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
             ?>";
410 410
         });
411 411
 
412
-        $blade->directive('pushonce', function ($expression) {
412
+        $blade->directive('pushonce', function($expression) {
413 413
             [$pushName, $pushSub] = explode(':', trim(substr($expression, 1, -1)));
414 414
             $key = '__pushonce_' . $pushName . '_' . str_replace('-', '_', $pushSub);
415 415
             return "<?php if(! isset(\$__env->{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>";
416 416
         });
417 417
 
418
-        $blade->directive('endpushonce', function () {
418
+        $blade->directive('endpushonce', function() {
419 419
             return '<?php $__env->stopPush(); endif; ?>';
420 420
         });
421 421
 
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 
457 457
         View::composer('twill::partials.navigation.*', ActiveNavigation::class);
458 458
 
459
-        View::composer(['twill.*', 'templates.*', 'twill::*'], function ($view) {
459
+        View::composer(['twill.*', 'templates.*', 'twill::*'], function($view) {
460 460
             $with = array_merge([
461 461
                 'renderForBlocks' => false,
462 462
                 'renderForModal' => false,
Please login to merge, or discard this patch.
src/Exceptions/Handler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
         if ($frontend) {
55 55
             $view = config('twill.frontend.views_path') . ".errors.$statusCode";
56 56
 
57
-            return view()->exists($view)? $view : "errors::{$statusCode}";
57
+            return view()->exists($view) ? $view : "errors::{$statusCode}";
58 58
         }
59 59
 
60 60
         $view = "twill.errors.$statusCode";
Please login to merge, or discard this patch.
src/Models/Behaviors/HasMedias.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
     public static function bootHasMedias(): void
21 21
     {
22
-        self::deleted(static function (Model $model) {
22
+        self::deleted(static function(Model $model) {
23 23
             if (!method_exists($model, 'isForceDeleting') || $model->isForceDeleting()) {
24 24
                 /** @var \A17\Twill\Models\Behaviors\HasMedias $model */
25 25
                 $model->medias()->detach();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     private function findMedia($role, $crop = "default")
56 56
     {
57 57
         $foundMedia = false;
58
-        $media = $this->medias->first(function ($media) use ($role, $crop, &$foundMedia) {
58
+        $media = $this->medias->first(function($media) use ($role, $crop, &$foundMedia) {
59 59
             if (config('twill.media_library.translated_form_fields', false)) {
60 60
                 $localeScope = $media->pivot->locale === app()->getLocale();
61 61
             }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         });
69 69
 
70 70
         if (!$media && config('twill.media_library.translated_form_fields', false)) {
71
-            $media = $this->medias->first(function ($media) use ($role, $crop, &$foundMedia) {
71
+            $media = $this->medias->first(function($media) use ($role, $crop, &$foundMedia) {
72 72
                 if (!$foundMedia) {
73 73
                     $foundMedia = $media->pivot->role === $role;
74 74
                 }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function images($role, $crop = "default", $params = [])
148 148
     {
149
-        $medias = $this->medias->filter(function ($media) use ($role, $crop) {
149
+        $medias = $this->medias->filter(function($media) use ($role, $crop) {
150 150
             return $media->pivot->role === $role && $media->pivot->crop === $crop;
151 151
         });
152 152
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function imagesWithCrops($role, $params = [])
170 170
     {
171
-        $medias = $this->medias->filter(function ($media) use ($role) {
171
+        $medias = $this->medias->filter(function($media) use ($role) {
172 172
             return $media->pivot->role === $role;
173 173
         });
174 174
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function imagesAsArrays($role, $crop = "default", $params = [])
223 223
     {
224
-        $medias = $this->medias->filter(function ($media) use ($role, $crop) {
224
+        $medias = $this->medias->filter(function($media) use ($role, $crop) {
225 225
             return $media->pivot->role === $role && $media->pivot->crop === $crop;
226 226
         });
227 227
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     public function imagesAsArraysWithCrops($role, $params = [])
245 245
     {
246
-        $medias = $this->medias->filter(function ($media) use ($role) {
246
+        $medias = $this->medias->filter(function($media) use ($role) {
247 247
             return $media->pivot->role === $role;
248 248
         });
249 249
 
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
     public function imageAltText($role, $media = null)
268 268
     {
269 269
         if (!$media) {
270
-            $media = $this->medias->first(function ($media) use ($role) {
270
+            $media = $this->medias->first(function($media) use ($role) {
271 271
                 if (config('twill.media_library.translated_form_fields', false)) {
272 272
                     $localeScope = $media->pivot->locale === app()->getLocale();
273 273
                 }
274 274
 
275
-                return $media->pivot->role === $role && ($localeScope ?? true);;
275
+                return $media->pivot->role === $role && ($localeScope ?? true); ;
276 276
             });
277 277
         }
278 278
 
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
     public function imageCaption($role, $media = null)
294 294
     {
295 295
         if (!$media) {
296
-            $media = $this->medias->first(function ($media) use ($role) {
296
+            $media = $this->medias->first(function($media) use ($role) {
297 297
                 if (config('twill.media_library.translated_form_fields', false)) {
298 298
                     $localeScope = $media->pivot->locale === app()->getLocale();
299 299
                 }
300 300
 
301
-                return $media->pivot->role === $role && ($localeScope ?? true);;
301
+                return $media->pivot->role === $role && ($localeScope ?? true); ;
302 302
             });
303 303
         }
304 304
 
@@ -319,12 +319,12 @@  discard block
 block discarded – undo
319 319
     public function imageVideo($role, $media = null)
320 320
     {
321 321
         if (!$media) {
322
-            $media = $this->medias->first(function ($media) use ($role) {
322
+            $media = $this->medias->first(function($media) use ($role) {
323 323
                 if (config('twill.media_library.translated_form_fields', false)) {
324 324
                     $localeScope = $media->pivot->locale === app()->getLocale();
325 325
                 }
326 326
 
327
-                return $media->pivot->role === $role && ($localeScope ?? true);;
327
+                return $media->pivot->role === $role && ($localeScope ?? true); ;
328 328
             });
329 329
         }
330 330
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
      */
442 442
     public function imageObjects($role, $crop = "default")
443 443
     {
444
-        return $this->medias->filter(function ($media) use ($role, $crop) {
444
+        return $this->medias->filter(function($media) use ($role, $crop) {
445 445
             return $media->pivot->role === $role && $media->pivot->crop === $crop;
446 446
         });
447 447
     }
Please login to merge, or discard this patch.