@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | if (Schema::hasTable(config('twill.related_table', 'related'))) { |
46 | 46 | $relatedItems = Collection::make(); |
47 | 47 | |
48 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object, &$relatedItems) { |
|
49 | - Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) { |
|
48 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object, &$relatedItems) { |
|
49 | + Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) { |
|
50 | 50 | try { |
51 | 51 | $repository = $this->getModelRepository($item['endpointType'] ?? $browserName); |
52 | 52 | $relatedItems->push((object) [ |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function afterSave($object, $fields) |
74 | 74 | { |
75 | 75 | if (Schema::hasTable(config('twill.related_table', 'related'))) { |
76 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) { |
|
76 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) { |
|
77 | 77 | $object->saveRelated($items, $browserName); |
78 | 78 | }); |
79 | 79 | } |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | { |
101 | 101 | $blocksFromConfig = $this->config->get('twill.block_editor.' . ($repeater ? 'repeaters' : 'blocks')); |
102 | 102 | |
103 | - $block['type'] = Collection::make($blocksFromConfig)->search(function ($blockConfig) use ($block) { |
|
103 | + $block['type'] = Collection::make($blocksFromConfig)->search(function($blockConfig) use ($block) { |
|
104 | 104 | return $blockConfig['component'] === $block['type']; |
105 | 105 | }); |
106 | 106 | |
107 | 107 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
108 | 108 | |
109 | 109 | if ($block['browsers']) { |
110 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
110 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
111 | 111 | return Collection::make($items)->pluck('id'); |
112 | 112 | })->toArray(); |
113 | 113 |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | |
72 | 72 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
73 | 73 | |
74 | - $this->getBlocks($object, $fields)->each(function ($block) use ($object, $blockRepository) { |
|
74 | + $this->getBlocks($object, $fields)->each(function($block) use ($object, $blockRepository) { |
|
75 | 75 | |
76 | 76 | $blockCreated = $blockRepository->create($block); |
77 | 77 | |
78 | - $block['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
78 | + $block['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
79 | 79 | $childBlock['parent_id'] = $blockCreated->id; |
80 | 80 | $blockRepository->create($childBlock); |
81 | 81 | }); |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | ]; |
175 | 175 | } |
176 | 176 | |
177 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
177 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
178 | 178 | return $key !== "browsers"; |
179 | - })->map(function ($value, $key) use ($block) { |
|
179 | + })->map(function($value, $key) use ($block) { |
|
180 | 180 | return [ |
181 | 181 | 'name' => "blocks[$block->id][$key]", |
182 | 182 | 'value' => $value, |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | |
190 | 190 | if ($medias) { |
191 | 191 | if (config('twill.media_library.translated_form_fields', false)) { |
192 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
193 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
192 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
193 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
194 | 194 | return [ |
195 | 195 | "blocks[$block->id][$key][$locale]" => $value, |
196 | 196 | ]; |
197 | 197 | }); |
198 | 198 | })->filter()->toArray(); |
199 | 199 | } else { |
200 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
200 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
201 | 201 | return [ |
202 | 202 | "blocks[$block->id][$key]" => $value, |
203 | 203 | ]; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | $files = $blockFormFields['files']; |
209 | 209 | |
210 | 210 | if ($files) { |
211 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
212 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
211 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
212 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
213 | 213 | return [ |
214 | 214 | "blocks[$block->id][$role][$locale]" => $files, |
215 | 215 | ]; |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | */ |
249 | 249 | protected function getBlockBrowsers($block) |
250 | 250 | { |
251 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
251 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
252 | 252 | if (Schema::hasTable(config('twill.related_table', 'related')) && $block->getRelated($relation)->isNotEmpty()) { |
253 | - $items = $this->getFormFieldsForRelatedBrowser($block, $relation);; |
|
253 | + $items = $this->getFormFieldsForRelatedBrowser($block, $relation); ; |
|
254 | 254 | } else { |
255 | 255 | $relationRepository = $this->getModelRepository($relation); |
256 | 256 | $relatedItems = $relationRepository->get([], ['id' => $ids], [], -1); |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | $sortedRelatedItems[$item->id] = $item; |
261 | 261 | } |
262 | 262 | |
263 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
263 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
264 | 264 | return is_object($value); |
265 | - })->map(function ($relatedElement) use ($relation) { |
|
265 | + })->map(function($relatedElement) use ($relation) { |
|
266 | 266 | return [ |
267 | 267 | 'id' => $relatedElement->id, |
268 | 268 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -102,7 +102,7 @@ |
||
102 | 102 | 'hasFiles', |
103 | 103 | 'hasPosition', |
104 | 104 | 'hasRevisions', |
105 | - ])->filter(function ($enabled) { |
|
105 | + ])->filter(function($enabled) { |
|
106 | 106 | return $enabled; |
107 | 107 | }); |
108 | 108 |