@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $blockRepository = app(BlockRepository::class); |
71 | 71 | |
72 | 72 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
73 | - $this->getBlocks($object, $fields)->each(function ($block) use ($object, $blockRepository) { |
|
73 | + $this->getBlocks($object, $fields)->each(function($block) use ($object, $blockRepository) { |
|
74 | 74 | $this->createBlock($blockRepository, $block); |
75 | 75 | }); |
76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $blockCreated = $blockRepository->create($blockFields); |
89 | 89 | |
90 | 90 | // Handle child blocks |
91 | - $blockFields['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
91 | + $blockFields['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
92 | 92 | $childBlock['parent_id'] = $blockCreated->id; |
93 | 93 | $this->createBlock($blockRepository, $childBlock); |
94 | 94 | }); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | ]; |
201 | 201 | } |
202 | 202 | |
203 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
203 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
204 | 204 | return $key !== "browsers"; |
205 | - })->map(function ($value, $key) use ($block) { |
|
205 | + })->map(function($value, $key) use ($block) { |
|
206 | 206 | return [ |
207 | 207 | 'name' => "blocks[$block->id][$key]", |
208 | 208 | 'value' => $value, |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | |
216 | 216 | if ($medias) { |
217 | 217 | if (config('twill.media_library.translated_form_fields', false)) { |
218 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
219 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
218 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
219 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
220 | 220 | return [ |
221 | 221 | "blocks[$block->id][$key][$locale]" => $value, |
222 | 222 | ]; |
223 | 223 | }); |
224 | 224 | })->filter()->toArray(); |
225 | 225 | } else { |
226 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
226 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
227 | 227 | return [ |
228 | 228 | "blocks[$block->id][$key]" => $value, |
229 | 229 | ]; |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | $files = $blockFormFields['files']; |
235 | 235 | |
236 | 236 | if ($files) { |
237 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
238 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
237 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
238 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
239 | 239 | return [ |
240 | 240 | "blocks[$block->id][$role][$locale]" => $files, |
241 | 241 | ]; |
@@ -274,9 +274,9 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function getBlockBrowsers($block) |
276 | 276 | { |
277 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
277 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
278 | 278 | if (Schema::hasTable(config('twill.related_table', 'twill_related')) && $block->getRelated($relation)->isNotEmpty()) { |
279 | - $items = $this->getFormFieldsForRelatedBrowser($block, $relation);; |
|
279 | + $items = $this->getFormFieldsForRelatedBrowser($block, $relation); ; |
|
280 | 280 | } else { |
281 | 281 | $relationRepository = $this->getModelRepository($relation); |
282 | 282 | $relatedItems = $relationRepository->get([], ['id' => $ids], [], -1); |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | $sortedRelatedItems[$item->id] = $item; |
287 | 287 | } |
288 | 288 | |
289 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
289 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
290 | 290 | return is_object($value); |
291 | - })->map(function ($relatedElement) use ($relation) { |
|
291 | + })->map(function($relatedElement) use ($relation) { |
|
292 | 292 | return [ |
293 | 293 | 'id' => $relatedElement->id, |
294 | 294 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $relationRepository = $this->getModelRepository($relation, $model); |
63 | 63 | |
64 | 64 | if (!$keepExisting) { |
65 | - $object->$relation()->each(function ($repeaterElement) { |
|
65 | + $object->$relation()->each(function($repeaterElement) { |
|
66 | 66 | $repeaterElement->forceDelete(); |
67 | 67 | }); |
68 | 68 | } |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | $morph = $morph ?: $relation; |
83 | 83 | |
84 | - $morphFieldType = $morph.'_type'; |
|
85 | - $morphFieldId = $morph.'_id'; |
|
84 | + $morphFieldType = $morph . '_type'; |
|
85 | + $morphFieldId = $morph . '_id'; |
|
86 | 86 | |
87 | 87 | // if no relation field submitted, soft deletes all associated rows |
88 | 88 | if (!$relationFields) { |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | |
233 | 233 | if (isset($relatedItemFormFields['medias'])) { |
234 | 234 | if (config('twill.media_library.translated_form_fields', false)) { |
235 | - Collection::make($relatedItemFormFields['medias'])->each(function ($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) { |
|
236 | - $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function ($medias, $role) use ($locale, $relation, $relationItem) { |
|
235 | + Collection::make($relatedItemFormFields['medias'])->each(function($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) { |
|
236 | + $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function($medias, $role) use ($locale, $relation, $relationItem) { |
|
237 | 237 | return [ |
238 | 238 | "blocks[$relation-$relationItem->id][$role][$locale]" => $medias, |
239 | 239 | ]; |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | if (isset($relatedItemFormFields['files'])) { |
250 | - Collection::make($relatedItemFormFields['files'])->each(function ($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
251 | - $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $relation, $relationItem) { |
|
250 | + Collection::make($relatedItemFormFields['files'])->each(function($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
251 | + $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $relation, $relationItem) { |
|
252 | 252 | return [ |
253 | 253 | "blocks[$relation-$relationItem->id][$role][$locale]" => $files, |
254 | 254 | ]; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | */ |
299 | 299 | protected function getRepeaters() |
300 | 300 | { |
301 | - return collect($this->repeaters)->map(function ($repeater, $key) { |
|
301 | + return collect($this->repeaters)->map(function($repeater, $key) { |
|
302 | 302 | $repeaterName = is_string($repeater) ? $repeater : $key; |
303 | 303 | return [ |
304 | 304 | 'relation' => !empty($repeater['relation']) ? $repeater['relation'] : $this->inferRelationFromRepeaterName($repeaterName), |
@@ -142,11 +142,11 @@ |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * Get all browser' detail info from the $browsers attribute. |
|
146 | - * The missing information will be inferred by convention of Twill. |
|
147 | - * |
|
148 | - * @return Illuminate\Support\Collection |
|
149 | - */ |
|
145 | + * Get all browser' detail info from the $browsers attribute. |
|
146 | + * The missing information will be inferred by convention of Twill. |
|
147 | + * |
|
148 | + * @return Illuminate\Support\Collection |
|
149 | + */ |
|
150 | 150 | protected function getBrowsers() |
151 | 151 | { |
152 | 152 | return collect($this->browsers)->map(function ($browser, $key) { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getFormFieldsForBrowser($object, $relation, $routePrefix = null, $titleKey = 'title', $moduleName = null) |
109 | 109 | { |
110 | - return $object->$relation->map(function ($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
110 | + return $object->$relation->map(function($relatedElement) use ($titleKey, $routePrefix, $relation, $moduleName) { |
|
111 | 111 | return [ |
112 | 112 | 'id' => $relatedElement->id, |
113 | 113 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->$titleKey, |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getFormFieldsForRelatedBrowser($object, $relation) |
128 | 128 | { |
129 | - return $object->getRelated($relation)->map(function ($relatedElement) { |
|
129 | + return $object->getRelated($relation)->map(function($relatedElement) { |
|
130 | 130 | return ($relatedElement != null) ? [ |
131 | 131 | 'id' => $relatedElement->id, |
132 | 132 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ]) + (classHasTrait($relatedElement, HasMedias::class) ? [ |
137 | 137 | 'thumbnail' => $relatedElement->defaultCmsImage(['w' => 100, 'h' => 100]), |
138 | 138 | ] : []) : []; |
139 | - })->reject(function ($item) { |
|
139 | + })->reject(function($item) { |
|
140 | 140 | return empty($item); |
141 | 141 | })->values()->toArray(); |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | protected function getBrowsers() |
151 | 151 | { |
152 | - return collect($this->browsers)->map(function ($browser, $key) { |
|
152 | + return collect($this->browsers)->map(function($browser, $key) { |
|
153 | 153 | $browserName = is_string($browser) ? $browser : $key; |
154 | 154 | return [ |
155 | 155 | 'relation' => !empty($browser['relation']) ? $browser['relation'] : $this->inferRelationFromBrowserName($browserName), |
@@ -79,7 +79,7 @@ |
||
79 | 79 | |
80 | 80 | if (!$item && config('translatable.use_property_fallback', false) |
81 | 81 | && config('translatable.fallback_locale') != config('app.locale')) { |
82 | - $item = (clone $query)->orWhere(function ($query) { |
|
82 | + $item = (clone $query)->orWhere(function($query) { |
|
83 | 83 | return $query->withActiveTranslations(config('translatable.fallback_locale')); |
84 | 84 | })->forFallbackLocaleSlug($slug)->first(); |
85 | 85 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | if ($object->$group) { |
39 | 39 | $decoded_fields = json_decode($object->$group, true) ?? []; |
40 | 40 | // In case that some field read the value through $item->$name |
41 | - foreach($decoded_fields as $field_name => $field_value) { |
|
41 | + foreach ($decoded_fields as $field_name => $field_value) { |
|
42 | 42 | $object->setAttribute($field_name, $field_value); |
43 | 43 | } |
44 | 44 | $fields = array_merge($fields, $decoded_fields); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function handleFieldsGroups($fields) { |
52 | 52 | foreach ($this->fieldsGroups as $group => $groupFields) { |
53 | - $fields[$group] = Arr::where(Arr::only($fields, $groupFields), function ($value, $key) { |
|
53 | + $fields[$group] = Arr::where(Arr::only($fields, $groupFields), function($value, $key) { |
|
54 | 54 | return !empty($value); |
55 | 55 | }); |
56 | 56 | Arr::forget($fields, $groupFields); |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | private function mapHostRoutes($router, $groupOptions, $middlewares, $supportSubdomainRouting) |
69 | 69 | { |
70 | 70 | if (file_exists(base_path('routes/admin.php'))) { |
71 | - $hostRoutes = function ($router) use ($middlewares) { |
|
71 | + $hostRoutes = function($router) use ($middlewares) { |
|
72 | 72 | $router->group([ |
73 | 73 | 'namespace' => config('twill.namespace', 'App') . '\Http\Controllers\Admin', |
74 | 74 | 'middleware' => $middlewares, |
75 | - ], function ($router) { |
|
75 | + ], function($router) { |
|
76 | 76 | require base_path('routes/admin.php'); |
77 | 77 | }); |
78 | 78 | }; |
@@ -91,25 +91,25 @@ discard block |
||
91 | 91 | |
92 | 92 | private function mapInternalRoutes($router, $groupOptions, $middlewares, $supportSubdomainRouting) |
93 | 93 | { |
94 | - $internalRoutes = function ($router) use ($middlewares, $supportSubdomainRouting) { |
|
95 | - $router->group(['middleware' => $middlewares], function ($router) { |
|
94 | + $internalRoutes = function($router) use ($middlewares, $supportSubdomainRouting) { |
|
95 | + $router->group(['middleware' => $middlewares], function($router) { |
|
96 | 96 | require __DIR__ . '/../routes/admin.php'; |
97 | 97 | }); |
98 | 98 | |
99 | 99 | $router->group([ |
100 | 100 | 'middleware' => $supportSubdomainRouting ? ['supportSubdomainRouting'] : [], |
101 | - ], function ($router) { |
|
101 | + ], function($router) { |
|
102 | 102 | require __DIR__ . '/../routes/auth.php'; |
103 | 103 | }); |
104 | 104 | |
105 | - $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function ($router) { |
|
105 | + $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function($router) { |
|
106 | 106 | require __DIR__ . '/../routes/templates.php'; |
107 | 107 | }); |
108 | 108 | }; |
109 | 109 | |
110 | 110 | $router->group($groupOptions + [ |
111 | 111 | 'namespace' => $this->namespace . '\Admin', |
112 | - ], function ($router) use ($internalRoutes, $supportSubdomainRouting) { |
|
112 | + ], function($router) use ($internalRoutes, $supportSubdomainRouting) { |
|
113 | 113 | $router->group([ |
114 | 114 | 'domain' => config('twill.admin_app_url'), |
115 | 115 | ], $internalRoutes); |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | 'domain' => config('app.url'), |
128 | 128 | 'middleware' => [config('twill.admin_middleware_group', 'web')], |
129 | 129 | ], |
130 | - function ($router) { |
|
131 | - $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function ($router) { |
|
130 | + function($router) { |
|
131 | + $router->group(['middleware' => $this->app->environment('production') ? ['twill_auth:twill_users'] : []], function($router) { |
|
132 | 132 | require __DIR__ . '/../routes/templates.php'; |
133 | 133 | }); |
134 | 134 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function registerMacros() |
164 | 164 | { |
165 | - Route::macro('moduleShowWithPreview', function ($moduleName, $routePrefix = null, $controllerName = null) { |
|
165 | + Route::macro('moduleShowWithPreview', function($moduleName, $routePrefix = null, $controllerName = null) { |
|
166 | 166 | if ($routePrefix === null) { |
167 | 167 | $routePrefix = $moduleName; |
168 | 168 | } |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | Route::name($moduleName . '.preview')->get('/admin-preview' . $routePrefix . '{slug}', $controllerName . 'Controller@show')->middleware(['web', 'twill_auth:twill_users', 'can:list']); |
179 | 179 | }); |
180 | 180 | |
181 | - Route::macro('module', function ($slug, $options = [], $resource_options = [], $resource = true) { |
|
181 | + Route::macro('module', function($slug, $options = [], $resource_options = [], $resource = true) { |
|
182 | 182 | |
183 | 183 | $slugs = explode('.', $slug); |
184 | 184 | $prefixSlug = str_replace('.', "/", $slug); |
185 | 185 | $_slug = Arr::last($slugs); |
186 | - $className = implode("", array_map(function ($s) { |
|
186 | + $className = implode("", array_map(function($s) { |
|
187 | 187 | return ucfirst(Str::singular($s)); |
188 | 188 | }, $slugs)); |
189 | 189 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | if ($resource) { |
232 | 232 | $customRoutePrefix = !empty($groupPrefix) ? "{$groupPrefix}." : ""; |
233 | - Route::group(['as' => $customRoutePrefix], function () use ($slug, $className, $resource_options) { |
|
233 | + Route::group(['as' => $customRoutePrefix], function() use ($slug, $className, $resource_options) { |
|
234 | 234 | Route::resource($slug, "{$className}Controller", $resource_options); |
235 | 235 | }); |
236 | 236 | } |