@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | public function scopeEditor($query, $name = 'default') |
| 35 | 35 | { |
| 36 | 36 | return $name === 'default' ? |
| 37 | - $query->where('editor_name', $name)->orWhereNull('editor_name') : |
|
| 38 | - $query->where('editor_name', $name); |
|
| 37 | + $query->where('editor_name', $name)->orWhereNull('editor_name') : $query->where('editor_name', $name); |
|
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | public function blockable() |
@@ -85,11 +84,11 @@ discard block |
||
| 85 | 84 | { |
| 86 | 85 | $blocks = self::where('parent_id', $this->id)->where('child_key', $editor)->get(); |
| 87 | 86 | |
| 88 | - return $blocks->map(function ($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 87 | + return $blocks->map(function($block) use ($blockViewMappings, $renderChilds, $data) { |
|
| 89 | 88 | if ($renderChilds) { |
| 90 | 89 | $childBlocks = self::where('parent_id', $block->id)->get(); |
| 91 | 90 | |
| 92 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($blockViewMappings, $data) { |
|
| 91 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($blockViewMappings, $data) { |
|
| 93 | 92 | $view = $this->getBlockView($childBlock->type, $blockViewMappings); |
| 94 | 93 | return view($view, $data)->with('block', $childBlock)->render(); |
| 95 | 94 | })->implode(''); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $blockRepository = app(BlockRepository::class); |
| 82 | 82 | |
| 83 | 83 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
| 84 | - $this->getBlocks($object, $fields)->each(function ($block) use ($object, $blockRepository) { |
|
| 84 | + $this->getBlocks($object, $fields)->each(function($block) use ($object, $blockRepository) { |
|
| 85 | 85 | $this->createBlock($blockRepository, $block); |
| 86 | 86 | }); |
| 87 | 87 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $blockCreated = $blockRepository->create($blockFields); |
| 99 | 99 | |
| 100 | 100 | // Handle child blocks |
| 101 | - $blockFields['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
| 101 | + $blockFields['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
| 102 | 102 | $childBlock['parent_id'] = $blockCreated->id; |
| 103 | 103 | $this->createBlock($blockRepository, $childBlock); |
| 104 | 104 | }); |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
| 219 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
| 220 | 220 | return $key !== "browsers"; |
| 221 | - })->map(function ($value, $key) use ($block) { |
|
| 221 | + })->map(function($value, $key) use ($block) { |
|
| 222 | 222 | return [ |
| 223 | 223 | 'name' => "blocks[$block->id][$key]", |
| 224 | 224 | 'value' => $value, |
@@ -231,15 +231,15 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | if ($medias) { |
| 233 | 233 | if (config('twill.media_library.translated_form_fields', false)) { |
| 234 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
| 235 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
| 234 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
| 235 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
| 236 | 236 | return [ |
| 237 | 237 | "blocks[$block->id][$key][$locale]" => $value, |
| 238 | 238 | ]; |
| 239 | 239 | }); |
| 240 | 240 | })->filter()->toArray(); |
| 241 | 241 | } else { |
| 242 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
| 242 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
| 243 | 243 | return [ |
| 244 | 244 | "blocks[$block->id][$key]" => $value, |
| 245 | 245 | ]; |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | $files = $blockFormFields['files']; |
| 251 | 251 | |
| 252 | 252 | if ($files) { |
| 253 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 254 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
| 253 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 254 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
| 255 | 255 | return [ |
| 256 | 256 | "blocks[$block->id][$role][$locale]" => $files, |
| 257 | 257 | ]; |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | protected function getBlockBrowsers($block) |
| 292 | 292 | { |
| 293 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
| 293 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
| 294 | 294 | if (Schema::hasTable(config('twill.related_table', 'twill_related')) && $block->getRelated($relation)->isNotEmpty()) { |
| 295 | 295 | $items = $this->getFormFieldsForRelatedBrowser($block, $relation); |
| 296 | 296 | foreach ($items as &$item) { |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 321 | $sortedRelatedItems[$item->id] = $item; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
| 324 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
| 325 | 325 | return is_object($value); |
| 326 | - })->map(function ($relatedElement) use ($relation) { |
|
| 326 | + })->map(function($relatedElement) use ($relation) { |
|
| 327 | 327 | return [ |
| 328 | 328 | 'id' => $relatedElement->id, |
| 329 | 329 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -208,8 +208,7 @@ |
||
| 208 | 208 | $fields['blocks']["blocks-{$block->parent_id}_{$block->child_key}"][] = $blockItem + [ |
| 209 | 209 | 'icon' => $blockTypeConfig['icon'], |
| 210 | 210 | ]; |
| 211 | - } |
|
| 212 | - else { |
|
| 211 | + } else { |
|
| 213 | 212 | $fields['blocks'][$blockItem['name']][] = $blockItem + [ |
| 214 | 213 | 'icon' => $blockTypeConfig['icon'], |
| 215 | 214 | ]; |