Passed
Pull Request — 2.x (#1446)
by Harings
13:09
created
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 = "admin.errors.$statusCode";
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleRevisions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
      */
18 18
     public function hydrateHandleRevisions($object, $fields)
19 19
     {
20
-        foreach($this->getRepeaters() as $repeater) {
20
+        foreach ($this->getRepeaters() as $repeater) {
21 21
             $this->hydrateRepeater($object, $fields, $repeater['relation'], $repeater['model']);
22 22
         }
23 23
 
24
-        foreach($this->getBrowsers() as $browser) {
24
+        foreach ($this->getBrowsers() as $browser) {
25 25
             $this->hydrateBrowser($object, $fields, $browser['relation'], $browser['positionAttribute'], $browser['model']);
26 26
         }
27 27
 
Please login to merge, or discard this patch.
src/Http/Controllers/Admin/DashboardController.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $modules = Collection::make($this->config->get('twill.dashboard.modules'));
110 110
 
111
-        return $modules->filter(function ($module) {
111
+        return $modules->filter(function($module) {
112 112
             return ($module['search'] ?? false);
113
-        })->map(function ($module) use ($request) {
113
+        })->map(function($module) use ($request) {
114 114
             $repository = $this->getRepository($module['name'], $module['repository'] ?? null);
115 115
 
116 116
             $found = $repository->cmsSearch($request->get('search'), $module['search_fields'] ?? ['title'])->take(10);
117 117
 
118
-            return $found->map(function ($item) use ($module) {
118
+            return $found->map(function($item) use ($module) {
119 119
                 try {
120 120
                     $author = $item->revisions()->latest()->first()->user->name ?? 'Admin';
121 121
                 } catch (\Exception $e) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function getAllActivities()
144 144
     {
145
-        return Activity::take(20)->latest()->get()->map(function ($activity) {
145
+        return Activity::take(20)->latest()->get()->map(function($activity) {
146 146
             return $this->formatActivity($activity);
147 147
         })->filter()->values();
148 148
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     private function getLoggedInUserActivities()
154 154
     {
155
-        return Activity::where('causer_id', $this->authFactory->guard('twill_users')->user()->id)->take(20)->latest()->get()->map(function ($activity) {
155
+        return Activity::where('causer_id', $this->authFactory->guard('twill_users')->user()->id)->take(20)->latest()->get()->map(function($activity) {
156 156
             return $this->formatActivity($activity);
157 157
         })->filter()->values();
158 158
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             'date' => $activity->created_at->toIso8601String(),
180 180
             'author' => $activity->causer->name ?? twillTrans('twill::lang.dashboard.unknown-author'),
181 181
             'name' => $activity->subject->titleInDashboard ?? $activity->subject->title,
182
-            'activity' => twillTrans('twill::lang.dashboard.activities.'.$activity->description),
182
+            'activity' => twillTrans('twill::lang.dashboard.activities.' . $activity->description),
183 183
         ] + (classHasTrait($activity->subject, HasMedias::class) ? [
184 184
             'thumbnail' => $activity->subject->defaultCmsImage(['w' => 100, 'h' => 100]),
185 185
         ] : []) + (!$activity->subject->trashed() ? [
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             return [];
206 206
         }
207 207
 
208
-        $statsByDate = Collection::make($response['rows'] ?? [])->map(function (array $dateRow) {
208
+        $statsByDate = Collection::make($response['rows'] ?? [])->map(function(array $dateRow) {
209 209
             return [
210 210
                 'date' => $dateRow[0],
211 211
                 'users' => (int) $dateRow[1],
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
             'yesterday',
221 221
             'week',
222 222
             'month',
223
-        ])->mapWithKeys(function ($period) use ($statsByDate) {
223
+        ])->mapWithKeys(function($period) use ($statsByDate) {
224 224
             $stats = $this->getPeriodStats($period, $statsByDate);
225 225
             return [
226 226
                 $period => [
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
                 'stats' => $stats = $statsByDate->first(),
258 258
                 'moreUsers' => $stats['users'] > $statsByDate->get(1)['users'],
259 259
                 'morePageViews' => $stats['pageViews'] > $statsByDate->get(1)['pageViews'],
260
-                'usersData' => $statsByDate->take(7)->map(function ($stat) {
260
+                'usersData' => $statsByDate->take(7)->map(function($stat) {
261 261
                     return $stat['users'];
262 262
                 }),
263
-                'pageViewsData' => $statsByDate->take(7)->map(function ($stat) {
263
+                'pageViewsData' => $statsByDate->take(7)->map(function($stat) {
264 264
                     return $stat['pageViews'];
265 265
                 }),
266 266
             ];
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
                 'stats' => $stats = $statsByDate->get(1),
270 270
                 'moreUsers' => $stats['users'] > $statsByDate->get(2)['users'],
271 271
                 'morePageViews' => $stats['pageViews'] > $statsByDate->get(2)['pageViews'],
272
-                'usersData' => $statsByDate->slice(1)->take(7)->map(function ($stat) {
272
+                'usersData' => $statsByDate->slice(1)->take(7)->map(function($stat) {
273 273
                     return $stat['users'];
274 274
                 }),
275
-                'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function ($stat) {
275
+                'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function($stat) {
276 276
                     return $stat['pageViews'];
277 277
                 }),
278 278
             ];
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
                 'stats' => $stats,
296 296
                 'moreUsers' => $stats['users'] > $compareStats['users'],
297 297
                 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'],
298
-                'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) {
298
+                'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) {
299 299
                     return $stat['users'];
300 300
                 }),
301
-                'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) {
301
+                'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) {
302 302
                     return $stat['pageViews'];
303 303
                 }),
304 304
             ];
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
                 'stats' => $stats,
322 322
                 'moreUsers' => $stats['users'] > $compareStats['users'],
323 323
                 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'],
324
-                'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) {
324
+                'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) {
325 325
                     return $stat['users'];
326 326
                 }),
327
-                'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) {
327
+                'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) {
328 328
                     return $stat['pageViews'];
329 329
                 }),
330 330
             ];
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
      */
351 351
     private function getShortcuts($modules)
352 352
     {
353
-        return $modules->filter(function ($module) {
353
+        return $modules->filter(function($module) {
354 354
             return ($module['count'] ?? false) || ($module['create'] ?? false);
355
-        })->map(function ($module) {
355
+        })->map(function($module) {
356 356
             $repository = $this->getRepository($module['name'], $module['repository'] ?? null);
357 357
 
358 358
             $moduleOptions = [
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
      */
390 390
     private function getDrafts($modules)
391 391
     {
392
-        return $modules->filter(function ($module) {
392
+        return $modules->filter(function($module) {
393 393
             return ($module['draft'] ?? false);
394
-        })->map(function ($module) {
394
+        })->map(function($module) {
395 395
             $repository = $this->getRepository($module['name'], $module['repository'] ?? null);
396 396
 
397 397
             $query = $repository->draft()->limit(3)->latest();
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
             $drafts = $query->get();
404 404
 
405
-            return $drafts->map(function ($draft) use ($module) {
405
+            return $drafts->map(function($draft) use ($module) {
406 406
                 return [
407 407
                     'type' => ucfirst($module['label_singular'] ?? Str::singular($module['name'])),
408 408
                     'name' => $draft->titleInDashboard ?? $draft->title,
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,7 @@
 block discarded – undo
125 125
                 $date = null;
126 126
                 if ($item->updated_at) {
127 127
                     $date = $item->updated_at->toIso8601String();
128
-                }
129
-                elseif ($item->created_at) {
128
+                } elseif ($item->created_at) {
130 129
                     $date = $item->created_at->toIso8601String();
131 130
                 }
132 131
 
Please login to merge, or discard this patch.
src/Jobs/ReorderNestedModuleItems.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
     public function handle()
27 27
     {
28
-        DB::transaction(function () {
28
+        DB::transaction(function() {
29 29
             app($this->modelClass)->saveTreeFromIds($this->ids);
30 30
         }, 3);
31 31
     }
Please login to merge, or discard this patch.
src/Repositories/Behaviors/HandleFieldsGroups.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,12 +85,12 @@
 block discarded – undo
85 85
     {
86 86
         foreach ($this->fieldsGroups as $group => $groupFields) {
87 87
             if ($this->fieldsGroupsFormFieldNamesAutoPrefix) {
88
-                $groupFields = array_map(function ($field_name) use ($group) {
88
+                $groupFields = array_map(function($field_name) use ($group) {
89 89
                     return $group . $this->fieldsGroupsFormFieldNameSeparator . $field_name;
90 90
                 }, $groupFields);
91 91
             }
92 92
 
93
-            $fields[$group] = Arr::where(Arr::only($fields, $groupFields), function ($value, $key) {
93
+            $fields[$group] = Arr::where(Arr::only($fields, $groupFields), function($value, $key) {
94 94
                 return !empty($value);
95 95
             });
96 96
 
Please login to merge, or discard this patch.
src/RouteServiceProvider.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
         $middlewares,
83 83
         $supportSubdomainRouting
84 84
     ) {
85
-        $internalRoutes = function ($router) use (
85
+        $internalRoutes = function($router) use (
86 86
             $middlewares,
87 87
             $supportSubdomainRouting
88 88
         ) {
89
-            $router->group(['middleware' => $middlewares], function ($router) {
89
+            $router->group(['middleware' => $middlewares], function($router) {
90 90
                 require __DIR__ . '/../routes/admin.php';
91 91
             });
92 92
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                     ? ['supportSubdomainRouting']
97 97
                     : [],
98 98
                 ],
99
-                function ($router) {
99
+                function($router) {
100 100
                     require __DIR__ . '/../routes/auth.php';
101 101
                 }
102 102
             );
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     ? ['twill_auth:twill_users']
108 108
                     : [],
109 109
                 ],
110
-                function ($router) {
110
+                function($router) {
111 111
                     require __DIR__ . '/../routes/templates.php';
112 112
                 }
113 113
             );
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $groupOptions + [
118 118
                 'namespace' => $this->namespace . '\Admin',
119 119
             ],
120
-            function ($router) use ($internalRoutes, $supportSubdomainRouting) {
120
+            function($router) use ($internalRoutes, $supportSubdomainRouting) {
121 121
                 $router->group(
122 122
                     [
123 123
                         'domain' => config('twill.admin_app_url'),
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
                         config('twill.admin_middleware_group', 'web'),
149 149
                     ],
150 150
                 ],
151
-                function ($router) {
151
+                function($router) {
152 152
                     $router->group(
153 153
                         [
154 154
                             'middleware' => $this->app->environment(
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                             ? ['twill_auth:twill_users']
158 158
                             : [],
159 159
                         ],
160
-                        function ($router) {
160
+                        function($router) {
161 161
                             require __DIR__ . '/../routes/templates.php';
162 162
                         }
163 163
                     );
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     protected function registerMacros()
212 212
     {
213
-        Route::macro('moduleShowWithPreview', function (
213
+        Route::macro('moduleShowWithPreview', function(
214 214
             $moduleName,
215 215
             $routePrefix = null,
216 216
             $controllerName = null
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 ->middleware(['web', 'twill_auth:twill_users', 'can:list']);
245 245
         });
246 246
 
247
-        Route::macro('module', function (
247
+        Route::macro('module', function(
248 248
             $slug,
249 249
             $options = [],
250 250
             $resource_options = [],
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             $_slug = Arr::last($slugs);
256 256
             $className = implode(
257 257
                 '',
258
-                array_map(function ($s) {
258
+                array_map(function($s) {
259 259
                     return ucfirst(Str::singular($s));
260 260
                 }, $slugs)
261 261
             );
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
             if ($resource) {
381 381
                 Route::group(
382 382
                     ['as' => $resourceCustomGroupPrefix],
383
-                    function () use ($slug, $className, $resource_options) {
383
+                    function() use ($slug, $className, $resource_options) {
384 384
                         Route::resource(
385 385
                             $slug,
386 386
                             "{$className}Controller",
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             }
392 392
         });
393 393
 
394
-        Route::macro('singleton', function (
394
+        Route::macro('singleton', function(
395 395
             $slug,
396 396
             $options = [],
397 397
             $resource_options = [],
Please login to merge, or discard this patch.
src/Services/MediaLibrary/TwicPics.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $domain = config('twill.twicpics.domain');
98 98
         $path = config('twill.twicpics.path');
99 99
 
100
-        if (! empty($path)) {
100
+        if (!empty($path)) {
101 101
             $path = "{$path}/";
102 102
         }
103 103
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         $params = $this->paramsProcessor->process($params);
128 128
 
129
-        $manipulations = collect($params)->map(function ($value, $key) {
129
+        $manipulations = collect($params)->map(function($value, $key) {
130 130
             return "{$key}={$value}";
131 131
         })->join('/');
132 132
 
Please login to merge, or discard this patch.
src/Models/Behaviors/HasNesting.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     public function getAncestorsSlug($locale = null)
39 39
     {
40 40
         return collect($this->ancestors ?? [])
41
-            ->map(function ($i) use ($locale) { return $i->getSlug($locale); })
41
+            ->map(function($i) use ($locale) { return $i->getSlug($locale); })
42 42
             ->implode('/');
43 43
     }
44 44
 
Please login to merge, or discard this patch.
src/Http/Controllers/Admin/ModuleController.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             "$this->viewPrefix.index",
362 362
             "twill::$this->moduleName.index",
363 363
             "twill::layouts.listing",
364
-        ])->first(function ($view) {
364
+        ])->first(function($view) {
365 365
             return View::exists($view);
366 366
         });
367 367
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
             "$this->viewPrefix.form",
471 471
             "twill::$this->moduleName.form",
472 472
             "twill::layouts.form",
473
-        ])->first(function ($view) {
473
+        ])->first(function($view) {
474 474
             return View::exists($view);
475 475
         });
476 476
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
             "$this->viewPrefix.form",
502 502
             "twill::$this->moduleName.form",
503 503
             "twill::layouts.form",
504
-        ])->first(function ($view) {
504
+        ])->first(function($view) {
505 505
             return View::exists($view);
506 506
         });
507 507
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             "$this->viewPrefix.form",
630 630
             "twill::$this->moduleName.form",
631 631
             "twill::layouts.form",
632
-        ])->first(function ($view) {
632
+        ])->first(function($view) {
633 633
             return View::exists($view);
634 634
         });
635 635
 
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
         $query = $this->request->input('q');
892 892
         $tags = $this->repository->getTags($query);
893 893
 
894
-        return Response::json(['items' => $tags->map(function ($tag) {
894
+        return Response::json(['items' => $tags->map(function($tag) {
895 895
             return $tag->name;
896 896
         })], 200);
897 897
     }
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
     protected function getIndexTableData($items)
980 980
     {
981 981
         $translated = $this->moduleHas('translations');
982
-        return $items->map(function ($item) use ($translated) {
983
-            $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function ($column) use ($item) {
982
+        return $items->map(function($item) use ($translated) {
983
+            $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function($column) use ($item) {
984 984
                 return $this->getItemColumnData($item, $column);
985 985
             })->toArray();
986 986
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
             'feature',
1241 1241
             'bulkFeature',
1242 1242
             'bulkDelete',
1243
-        ])->mapWithKeys(function ($endpoint) {
1243
+        ])->mapWithKeys(function($endpoint) {
1244 1244
             return [
1245 1245
                 $endpoint . 'Url' => $this->getIndexOption($endpoint) ? moduleRoute(
1246 1246
                     $this->moduleName,
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
      */
1259 1259
     protected function getIndexOption($option)
1260 1260
     {
1261
-        return once(function () use ($option) {
1261
+        return once(function() use ($option) {
1262 1262
             $customOptionNamesMapping = [
1263 1263
                 'store' => 'create',
1264 1264
             ];
@@ -1315,8 +1315,8 @@  discard block
 block discarded – undo
1315 1315
     {
1316 1316
         $withImage = $this->moduleHas('medias');
1317 1317
 
1318
-        return $items->map(function ($item) use ($withImage) {
1319
-            $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) {
1318
+        return $items->map(function($item) use ($withImage) {
1319
+            $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function($column) use ($item) {
1320 1320
                 return $this->getItemColumnData($item, $column);
1321 1321
             })->toArray();
1322 1322
 
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
                     $fieldSplitted = explode('|', $field);
1383 1383
                     if (count($fieldSplitted) > 1) {
1384 1384
                         $requestValue = $requestFilters[$key];
1385
-                        Collection::make($fieldSplitted)->each(function ($scopeKey) use (&$scope, $requestValue) {
1385
+                        Collection::make($fieldSplitted)->each(function($scopeKey) use (&$scope, $requestValue) {
1386 1386
                             $scope[$scopeKey] = $requestValue;
1387 1387
                         });
1388 1388
                     } else {
@@ -1558,11 +1558,11 @@  discard block
 block discarded – undo
1558 1558
      */
1559 1559
     protected function validateFormRequest()
1560 1560
     {
1561
-        $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function ($permission, $field) {
1561
+        $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function($permission, $field) {
1562 1562
             return Auth::guard('twill_users')->user()->cannot($permission);
1563 1563
         })->keys();
1564 1564
 
1565
-        $unauthorizedFields->each(function ($field) {
1565
+        $unauthorizedFields->each(function($field) {
1566 1566
             $this->request->offsetUnset($field);
1567 1567
         });
1568 1568
 
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
                 $singularName = Str::singular($name);
1615 1615
                 $modelClass = config('twill.namespace') . '\\Models\\' . Str::studly($singularName);
1616 1616
 
1617
-                if(!class_exists($modelClass)) {
1617
+                if (!class_exists($modelClass)) {
1618 1618
                     $modelClass = $this->getCapsuleByModule($name)['model'];
1619 1619
                 }
1620 1620
 
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
      */
1861 1861
     public function getRepeaterList()
1862 1862
     {
1863
-        return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function ($repeater) {
1863
+        return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function($repeater) {
1864 1864
             return [$repeater['name'] => $repeater];
1865 1865
         });
1866 1866
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1691,8 +1691,7 @@
 block discarded – undo
1691 1691
 
1692 1692
         try {
1693 1693
             return TwillCapsules::getCapsuleForModel($this->modelName)->getViewPrefix();
1694
-        }
1695
-        catch (NoCapsuleFoundException $e) {
1694
+        } catch (NoCapsuleFoundException $e) {
1696 1695
             return null;
1697 1696
         }
1698 1697
     }
Please login to merge, or discard this patch.