@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | if (config('twill.enabled.media-library')) { |
127 | - $this->app->singleton('imageService', function () { |
|
127 | + $this->app->singleton('imageService', function() { |
|
128 | 128 | return $this->app->make(config('twill.media_library.image_service')); |
129 | 129 | }); |
130 | 130 | } |
131 | 131 | |
132 | 132 | if (config('twill.enabled.file-library')) { |
133 | - $this->app->singleton('fileService', function () { |
|
133 | + $this->app->singleton('fileService', function() { |
|
134 | 134 | return $this->app->make(config('twill.file_library.file_service')); |
135 | 135 | }); |
136 | 136 | } |
@@ -307,20 +307,20 @@ discard block |
||
307 | 307 | { |
308 | 308 | $blade = $this->app['view']->getEngineResolver()->resolve('blade')->getCompiler(); |
309 | 309 | |
310 | - $blade->directive('dd', function ($param) { |
|
310 | + $blade->directive('dd', function($param) { |
|
311 | 311 | return "<?php dd({$param}); ?>"; |
312 | 312 | }); |
313 | 313 | |
314 | - $blade->directive('dumpData', function ($data) { |
|
314 | + $blade->directive('dumpData', function($data) { |
|
315 | 315 | return sprintf("<?php (new Symfony\Component\VarDumper\VarDumper)->dump(%s); exit; ?>", |
316 | 316 | null != $data ? $data : "get_defined_vars()"); |
317 | 317 | }); |
318 | 318 | |
319 | - $blade->directive('formField', function ($expression) { |
|
319 | + $blade->directive('formField', function($expression) { |
|
320 | 320 | return $this->includeView('partials.form._', $expression); |
321 | 321 | }); |
322 | 322 | |
323 | - $blade->directive('partialView', function ($expression) { |
|
323 | + $blade->directive('partialView', function($expression) { |
|
324 | 324 | |
325 | 325 | $expressionAsArray = str_getcsv($expression, ',', '\''); |
326 | 326 | |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | ?>"; |
357 | 357 | }); |
358 | 358 | |
359 | - $blade->directive('pushonce', function ($expression) { |
|
359 | + $blade->directive('pushonce', function($expression) { |
|
360 | 360 | list($pushName, $pushSub) = explode(':', trim(substr($expression, 1, -1))); |
361 | 361 | $key = '__pushonce_' . $pushName . '_' . str_replace('-', '_', $pushSub); |
362 | 362 | return "<?php if(! isset(\$__env->{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>"; |
363 | 363 | }); |
364 | 364 | |
365 | - $blade->directive('endpushonce', function () { |
|
365 | + $blade->directive('endpushonce', function() { |
|
366 | 366 | return '<?php $__env->stopPush(); endif; ?>'; |
367 | 367 | }); |
368 | 368 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | |
395 | 395 | View::composer('twill::partials.navigation.*', ActiveNavigation::class); |
396 | 396 | |
397 | - View::composer(['admin.*', 'templates.*', 'twill::*'], function ($view) { |
|
397 | + View::composer(['admin.*', 'templates.*', 'twill::*'], function($view) { |
|
398 | 398 | $with = array_merge([ |
399 | 399 | 'renderForBlocks' => false, |
400 | 400 | 'renderForModal' => false, |
@@ -108,14 +108,14 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -205,7 +205,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | private function mapHostRoutes($router, $groupOptions, $middlewares, $supportSubdomainRouting) |
71 | 71 | { |
72 | 72 | if (file_exists(base_path('routes/admin.php'))) { |
73 | - $hostRoutes = function ($router) use ($middlewares) { |
|
73 | + $hostRoutes = function($router) use ($middlewares) { |
|
74 | 74 | $router->group([ |
75 | 75 | 'namespace' => config('twill.namespace', 'App') . '\Http\Controllers\Admin', |
76 | 76 | 'middleware' => $middlewares, |
77 | - ], function ($router) { |
|
77 | + ], function($router) { |
|
78 | 78 | require base_path('routes/admin.php'); |
79 | 79 | }); |
80 | 80 | }; |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | |
94 | 94 | private function mapInternalRoutes($router, $groupOptions, $middlewares, $supportSubdomainRouting) |
95 | 95 | { |
96 | - $internalRoutes = function ($router) use ($middlewares, $supportSubdomainRouting) { |
|
97 | - $router->group(['middleware' => $middlewares], function ($router) { |
|
96 | + $internalRoutes = function($router) use ($middlewares, $supportSubdomainRouting) { |
|
97 | + $router->group(['middleware' => $middlewares], function($router) { |
|
98 | 98 | require __DIR__ . '/../routes/admin.php'; |
99 | 99 | }); |
100 | 100 | |
101 | 101 | $router->group([ |
102 | 102 | 'middleware' => $supportSubdomainRouting ? ['supportSubdomainRouting'] : [], |
103 | - ], function ($router) { |
|
103 | + ], function($router) { |
|
104 | 104 | require __DIR__ . '/../routes/auth.php'; |
105 | 105 | }); |
106 | 106 | |
107 | - $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function ($router) { |
|
107 | + $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function($router) { |
|
108 | 108 | require __DIR__ . '/../routes/templates.php'; |
109 | 109 | }); |
110 | 110 | }; |
111 | 111 | |
112 | 112 | $router->group($groupOptions + [ |
113 | 113 | 'namespace' => $this->namespace . '\Admin', |
114 | - ], function ($router) use ($internalRoutes, $supportSubdomainRouting) { |
|
114 | + ], function($router) use ($internalRoutes, $supportSubdomainRouting) { |
|
115 | 115 | $router->group([ |
116 | 116 | 'domain' => config('twill.admin_app_url'), |
117 | 117 | ], $internalRoutes); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | 'domain' => config('app.url'), |
130 | 130 | 'middleware' => [config('twill.admin_middleware_group', 'web')], |
131 | 131 | ], |
132 | - function ($router) { |
|
133 | - $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function ($router) { |
|
132 | + function($router) { |
|
133 | + $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function($router) { |
|
134 | 134 | require __DIR__ . '/../routes/templates.php'; |
135 | 135 | }); |
136 | 136 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | protected function registerMacros() |
167 | 167 | { |
168 | - Route::macro('moduleShowWithPreview', function ($moduleName, $routePrefix = null, $controllerName = null) { |
|
168 | + Route::macro('moduleShowWithPreview', function($moduleName, $routePrefix = null, $controllerName = null) { |
|
169 | 169 | if ($routePrefix === null) { |
170 | 170 | $routePrefix = $moduleName; |
171 | 171 | } |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | Route::name($moduleName . '.preview')->get('/admin-preview' . $routePrefix . '{slug}', $controllerName . 'Controller@show')->middleware(['web', 'twill_auth:twill_users', 'can:list']); |
182 | 182 | }); |
183 | 183 | |
184 | - Route::macro('module', function ($slug, $options = [], $resource_options = [], $resource = true) { |
|
184 | + Route::macro('module', function($slug, $options = [], $resource_options = [], $resource = true) { |
|
185 | 185 | |
186 | 186 | $slugs = explode('.', $slug); |
187 | 187 | $prefixSlug = str_replace('.', "/", $slug); |
188 | 188 | $_slug = Arr::last($slugs); |
189 | - $className = implode("", array_map(function ($s) { |
|
189 | + $className = implode("", array_map(function($s) { |
|
190 | 190 | return ucfirst(Str::singular($s)); |
191 | 191 | }, $slugs)); |
192 | 192 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | if ($resource) { |
260 | - Route::group(['as' => $resourceCustomGroupPrefix], function () use ($slug, $className, $resource_options) { |
|
260 | + Route::group(['as' => $resourceCustomGroupPrefix], function() use ($slug, $className, $resource_options) { |
|
261 | 261 | Route::resource($slug, "{$className}Controller", $resource_options); |
262 | 262 | }); |
263 | 263 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | "$this->viewPrefix.index", |
331 | 331 | "twill::$this->moduleName.index", |
332 | 332 | "twill::layouts.listing", |
333 | - ])->first(function ($view) { |
|
333 | + ])->first(function($view) { |
|
334 | 334 | return View::exists($view); |
335 | 335 | }); |
336 | 336 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | "$this->viewPrefix.form", |
422 | 422 | "twill::$this->moduleName.form", |
423 | 423 | "twill::layouts.form", |
424 | - ])->first(function ($view) { |
|
424 | + ])->first(function($view) { |
|
425 | 425 | return View::exists($view); |
426 | 426 | }); |
427 | 427 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | "$this->viewPrefix.form", |
538 | 538 | "twill::$this->moduleName.form", |
539 | 539 | "twill::layouts.form", |
540 | - ])->first(function ($view) { |
|
540 | + ])->first(function($view) { |
|
541 | 541 | return View::exists($view); |
542 | 542 | }); |
543 | 543 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | $query = $this->request->input('q'); |
785 | 785 | $tags = $this->repository->getTags($query); |
786 | 786 | |
787 | - return Response::json(['items' => $tags->map(function ($tag) { |
|
787 | + return Response::json(['items' => $tags->map(function($tag) { |
|
788 | 788 | return $tag->name; |
789 | 789 | })], 200); |
790 | 790 | } |
@@ -871,8 +871,8 @@ discard block |
||
871 | 871 | protected function getIndexTableData($items) |
872 | 872 | { |
873 | 873 | $translated = $this->moduleHas('translations'); |
874 | - return $items->map(function ($item) use ($translated) { |
|
875 | - $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function ($column) use ($item) { |
|
874 | + return $items->map(function($item) use ($translated) { |
|
875 | + $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function($column) use ($item) { |
|
876 | 876 | return $this->getItemColumnData($item, $column); |
877 | 877 | })->toArray(); |
878 | 878 | |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | 'feature', |
1130 | 1130 | 'bulkFeature', |
1131 | 1131 | 'bulkDelete', |
1132 | - ])->mapWithKeys(function ($endpoint) { |
|
1132 | + ])->mapWithKeys(function($endpoint) { |
|
1133 | 1133 | return [ |
1134 | 1134 | $endpoint . 'Url' => $this->getIndexOption($endpoint) ? moduleRoute( |
1135 | 1135 | $this->moduleName, $this->routePrefix, $endpoint, |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | */ |
1146 | 1146 | protected function getIndexOption($option) |
1147 | 1147 | { |
1148 | - return once(function () use ($option) { |
|
1148 | + return once(function() use ($option) { |
|
1149 | 1149 | $customOptionNamesMapping = [ |
1150 | 1150 | 'store' => 'create', |
1151 | 1151 | ]; |
@@ -1201,8 +1201,8 @@ discard block |
||
1201 | 1201 | { |
1202 | 1202 | $withImage = $this->moduleHas('medias'); |
1203 | 1203 | |
1204 | - return $items->map(function ($item) use ($withImage) { |
|
1205 | - $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) { |
|
1204 | + return $items->map(function($item) use ($withImage) { |
|
1205 | + $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function($column) use ($item) { |
|
1206 | 1206 | return $this->getItemColumnData($item, $column); |
1207 | 1207 | })->toArray(); |
1208 | 1208 | |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | $fieldSplitted = explode('|', $field); |
1269 | 1269 | if (count($fieldSplitted) > 1) { |
1270 | 1270 | $requestValue = $requestFilters[$key]; |
1271 | - Collection::make($fieldSplitted)->each(function ($scopeKey) use (&$scope, $requestValue) { |
|
1271 | + Collection::make($fieldSplitted)->each(function($scopeKey) use (&$scope, $requestValue) { |
|
1272 | 1272 | $scope[$scopeKey] = $requestValue; |
1273 | 1273 | }); |
1274 | 1274 | } else { |
@@ -1435,11 +1435,11 @@ discard block |
||
1435 | 1435 | */ |
1436 | 1436 | protected function validateFormRequest() |
1437 | 1437 | { |
1438 | - $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function ($permission, $field) { |
|
1438 | + $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function($permission, $field) { |
|
1439 | 1439 | return Auth::guard('twill_users')->user()->cannot($permission); |
1440 | 1440 | })->keys(); |
1441 | 1441 | |
1442 | - $unauthorizedFields->each(function ($field) { |
|
1442 | + $unauthorizedFields->each(function($field) { |
|
1443 | 1443 | $this->request->offsetUnset($field); |
1444 | 1444 | }); |
1445 | 1445 | |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | */ |
1680 | 1680 | public function getRepeaterList() |
1681 | 1681 | { |
1682 | - return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function ($repeater) { |
|
1682 | + return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function($repeater) { |
|
1683 | 1683 | return [$repeater['name'] => $repeater]; |
1684 | 1684 | }); |
1685 | 1685 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | { |
66 | 66 | return collect( |
67 | 67 | config('twill.block_editor.directories.source.icons') |
68 | - )->reduce(function (Collection $keep, $path) { |
|
68 | + )->reduce(function(Collection $keep, $path) { |
|
69 | 69 | if (!$this->files->exists($path)) { |
70 | 70 | $this->displayError("Directory not found: {$path}"); |
71 | 71 | |
72 | 72 | return $keep; |
73 | 73 | } |
74 | 74 | |
75 | - $files = collect($this->files->files($path))->map(function ( |
|
75 | + $files = collect($this->files->files($path))->map(function( |
|
76 | 76 | SplFileInfo $file |
77 | 77 | ) { |
78 | 78 | return [ |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function handle() |
94 | 94 | { |
95 | - $icons = $this->getIconList()->filter(function ($icon) { |
|
95 | + $icons = $this->getIconList()->filter(function($icon) { |
|
96 | 96 | return $this->isAllowed($icon); |
97 | 97 | }); |
98 | 98 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function byKey($key, $section = null) |
36 | 36 | { |
37 | - return $this->model->when($section, function ($query) use ($section) { |
|
37 | + return $this->model->when($section, function($query) use ($section) { |
|
38 | 38 | $query->where('section', $section); |
39 | 39 | })->where('key', $key)->exists() ? $this->model->where('key', $key)->with('translations')->first()->value : null; |
40 | 40 | } |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function getFormFields($section = null) |
47 | 47 | { |
48 | - $settings = $this->model->when($section, function ($query) use ($section) { |
|
48 | + $settings = $this->model->when($section, function($query) use ($section) { |
|
49 | 49 | $query->where('section', $section); |
50 | 50 | })->with('translations', 'medias')->get(); |
51 | 51 | |
52 | 52 | |
53 | 53 | if (config('twill.media_library.translated_form_fields', false)) { |
54 | - $medias = $settings->reduce(function ($carry, $setting) { |
|
54 | + $medias = $settings->reduce(function($carry, $setting) { |
|
55 | 55 | foreach (getLocales() as $locale) { |
56 | 56 | if (!empty(parent::getFormFields($setting)['medias'][$locale]) && !empty(parent::getFormFields($setting)['medias'][$locale][$setting->key])) |
57 | 57 | { |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | return $carry; |
62 | 62 | }); |
63 | 63 | } else { |
64 | - $medias = $settings->mapWithKeys(function ($setting) { |
|
64 | + $medias = $settings->mapWithKeys(function($setting) { |
|
65 | 65 | return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null]; |
66 | 66 | })->filter()->toArray(); |
67 | 67 | } |
68 | 68 | |
69 | - return $settings->mapWithKeys(function ($setting) { |
|
69 | + return $settings->mapWithKeys(function($setting) { |
|
70 | 70 | $settingValue = []; |
71 | 71 | |
72 | 72 | foreach ($setting->translations as $translation) { |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | |
118 | 118 | if (config('twill.media_library.translated_form_fields', false)) { |
119 | 119 | foreach (getLocales() as $locale) { |
120 | - $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function ($media) { |
|
120 | + $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function($media) { |
|
121 | 121 | return json_decode($media, true); |
122 | 122 | })->filter()->toArray(); |
123 | 123 | } |
124 | 124 | } else { |
125 | - $medias = [ |
|
126 | - $role => Collection::make($settingsFields['medias'][$role])->mapWithKeys(function ($media, $key) { |
|
125 | + $medias = [ |
|
126 | + $role => Collection::make($settingsFields['medias'][$role])->mapWithKeys(function($media, $key) { |
|
127 | 127 | return json_decode($media, true); |
128 | 128 | })->values()->filter()->toArray(), |
129 | 129 | ]; |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | public function findByName($search, $sources = []) |
51 | 51 | { |
52 | 52 | return $this->collect() |
53 | - ->filter(function ($block) use ($search, $sources) { |
|
53 | + ->filter(function($block) use ($search, $sources) { |
|
54 | 54 | return $block->name == $search && |
55 | 55 | (blank($sources) || |
56 | 56 | collect($sources)->contains($block->source)); |
57 | 57 | }) |
58 | - ->sortBy(function ($block) { |
|
58 | + ->sortBy(function($block) { |
|
59 | 59 | return $block->source === 'app' ? 0 : 1; |
60 | 60 | }) |
61 | 61 | ->first(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function getBlocks() |
68 | 68 | { |
69 | 69 | return $this->collect() |
70 | - ->filter(function ($block) { |
|
70 | + ->filter(function($block) { |
|
71 | 71 | return $block->type === Block::TYPE_BLOCK; |
72 | 72 | }) |
73 | 73 | ->values(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getBlockList() |
80 | 80 | { |
81 | - return $this->getBlocks()->map(function (Block $block) { |
|
81 | + return $this->getBlocks()->map(function(Block $block) { |
|
82 | 82 | return $block->toList(); |
83 | 83 | }); |
84 | 84 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return collect(); |
106 | 106 | } |
107 | 107 | |
108 | - return collect($this->fileSystem->files($directory))->map(function ( |
|
108 | + return collect($this->fileSystem->files($directory))->map(function( |
|
109 | 109 | $file |
110 | 110 | ) use ($source, $type) { |
111 | 111 | return new Block($file, $type, $source); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->paths = collect( |
121 | 121 | config('twill.block_editor.directories.source.blocks') |
122 | 122 | ) |
123 | - ->map(function ($path) { |
|
123 | + ->map(function($path) { |
|
124 | 124 | $path['type'] = Block::TYPE_BLOCK; |
125 | 125 | |
126 | 126 | return $path; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | ->merge( |
129 | 129 | collect( |
130 | 130 | config('twill.block_editor.directories.source.repeaters') |
131 | - )->map(function ($path) { |
|
131 | + )->map(function($path) { |
|
132 | 132 | $path['type'] = Block::TYPE_REPEATER; |
133 | 133 | |
134 | 134 | return $path; |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $this->generatePaths(); |
167 | 167 | |
168 | 168 | $this->items = collect($this->paths) |
169 | - ->reduce(function (Collection $keep, $path) { |
|
169 | + ->reduce(function(Collection $keep, $path) { |
|
170 | 170 | $this->readBlocks( |
171 | 171 | $path['path'], |
172 | 172 | $path['source'], |
173 | 173 | $path['type'] |
174 | - )->each(function ($block) use ($keep) { |
|
174 | + )->each(function($block) use ($keep) { |
|
175 | 175 | $keep->push($block); |
176 | 176 | |
177 | 177 | return $keep; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | ->toArray(); |
183 | 183 | |
184 | 184 | $this->items = $this->collect() |
185 | - ->each(function (Block $block) { |
|
185 | + ->each(function(Block $block) { |
|
186 | 186 | $block->setSource($this->detectCustomSources($block)); |
187 | 187 | }) |
188 | 188 | ->toArray(); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function list() |
205 | 205 | { |
206 | - return $this->collect()->map(function (Block $block) { |
|
206 | + return $this->collect()->map(function(Block $block) { |
|
207 | 207 | return $block->toList(); |
208 | 208 | }); |
209 | 209 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public function getRepeaters() |
223 | 223 | { |
224 | 224 | return $this->collect() |
225 | - ->filter(function ($block) { |
|
225 | + ->filter(function($block) { |
|
226 | 226 | return $block->type === Block::TYPE_REPEATER; |
227 | 227 | }) |
228 | 228 | ->values(); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function getRepeaterList() |
235 | 235 | { |
236 | - return $this->getRepeaters()->map(function (Block $block) { |
|
236 | + return $this->getRepeaters()->map(function(Block $block) { |
|
237 | 237 | return $block->toList(); |
238 | 238 | }); |
239 | 239 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | { |
38 | 38 | $this->call('twill:make:module', [ |
39 | 39 | 'moduleName' => $this->argument('moduleName'), |
40 | - ] + collect($this->options())->mapWithKeys(function ($value, $key) { |
|
40 | + ] + collect($this->options())->mapWithKeys(function($value, $key) { |
|
41 | 41 | return ["--{$key}" => $value]; |
42 | 42 | })->toArray()); |
43 | 43 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | if (!function_exists('dumpUsableSqlQuery')) { |
10 | 10 | function dumpUsableSqlQuery($query) |
11 | 11 | { |
12 | - dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function ($binding) { |
|
12 | + dd(vsprintf(str_replace('?', '%s', $query->toSql()), array_map(function($binding) { |
|
13 | 13 | return is_numeric($binding) ? $binding : "'{$binding}'"; |
14 | 14 | }, $query->getBindings()))); |
15 | 15 | } |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | { |
202 | 202 | $blockList = app(BlockCollection::class)->getBlockList(); |
203 | 203 | |
204 | - $appBlocksList = $blockList->filter(function ($block) { |
|
204 | + $appBlocksList = $blockList->filter(function($block) { |
|
205 | 205 | return $block['source'] !== A17\Twill\Services\Blocks\Block::SOURCE_TWILL; |
206 | 206 | }); |
207 | 207 | |
208 | 208 | return $blockList->filter( |
209 | - function ($block) use ($blocks, $groups, $appBlocksList) { |
|
209 | + function($block) use ($blocks, $groups, $appBlocksList) { |
|
210 | 210 | if ($block['group'] === A17\Twill\Services\Blocks\Block::SOURCE_TWILL) { |
211 | 211 | if (!collect( |
212 | 212 | config('twill.block_editor.use_twill_blocks') |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | if (count($appBlocksList) > 0 && $appBlocksList->contains( |
218 | - function ($appBlock) use ($block) { |
|
218 | + function($appBlock) use ($block) { |
|
219 | 219 | return $appBlock['name'] === $block['name']; |
220 | 220 | }) |
221 | 221 | ) { |