@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $featuredSources = $this->getFeaturedSources($request, $featuredSection, $filters['search'] ?? ''); |
| 44 | 44 | |
| 45 | - $contentTypes = Collection::make($featuredSources)->map(function ($source, $sourceKey) { |
|
| 45 | + $contentTypes = Collection::make($featuredSources)->map(function($source, $sourceKey) { |
|
| 46 | 46 | return [ |
| 47 | 47 | 'label' => $source['name'], |
| 48 | 48 | 'value' => $sourceKey, |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | return [ |
| 56 | 56 | 'source' => [ |
| 57 | - 'content_type' => Arr::first($contentTypes, function ($contentTypeItem) use ($request) { |
|
| 57 | + 'content_type' => Arr::first($contentTypes, function($contentTypeItem) use ($request) { |
|
| 58 | 58 | return $contentTypeItem['value'] == $request->get('content_type'); |
| 59 | 59 | }), |
| 60 | 60 | 'items' => $source['items'], |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | private function getFeaturedItemsByBucket($featuredSection, $featuredSectionKey) |
| 100 | 100 | { |
| 101 | 101 | $bucketRouteConfig = $this->config->get('twill.bucketsRoutes') ?? [$featuredSectionKey => 'featured']; |
| 102 | - return Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) { |
|
| 102 | + return Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) { |
|
| 103 | 103 | $routePrefix = $bucketRouteConfig[$featuredSectionKey]; |
| 104 | 104 | return [ |
| 105 | 105 | 'id' => $bucketKey, |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'acceptedSources' => Collection::make($bucket['bucketables'])->pluck('module'), |
| 109 | 109 | 'withToggleFeatured' => $bucket['with_starred_items'] ?? false, |
| 110 | 110 | 'toggleFeaturedLabels' => $bucket['starred_items_labels'] ?? [], |
| 111 | - 'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function ($feature) { |
|
| 111 | + 'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function($feature) { |
|
| 112 | 112 | if (($item = $feature->featured) != null) { |
| 113 | 113 | $repository = $this->getRepository($feature->featured_type); |
| 114 | 114 | $withImage = classHasTrait($repository, HandleMedias::class); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | 'thumbnail' => $item->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 127 | 127 | ] : []); |
| 128 | 128 | } |
| 129 | - })->reject(function ($item) { |
|
| 129 | + })->reject(function($item) { |
|
| 130 | 130 | return is_null($item); |
| 131 | 131 | })->values()->toArray(), |
| 132 | 132 | ]; |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | $fetchedModules = []; |
| 145 | 145 | $featuredSources = []; |
| 146 | 146 | |
| 147 | - Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use (&$fetchedModules, $search, $request) { |
|
| 148 | - return Collection::make($bucket['bucketables'])->mapWithKeys(function ($bucketable) use (&$fetchedModules, $bucketKey, $search, $request) { |
|
| 147 | + Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use (&$fetchedModules, $search, $request) { |
|
| 148 | + return Collection::make($bucket['bucketables'])->mapWithKeys(function($bucketable) use (&$fetchedModules, $bucketKey, $search, $request) { |
|
| 149 | 149 | |
| 150 | 150 | $module = $bucketable['module']; |
| 151 | 151 | $repository = $this->getRepository($module); |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | 'withImage' => $withImage, |
| 175 | 175 | ]]; |
| 176 | 176 | }); |
| 177 | - })->each(function ($bucketables, $bucket) use (&$featuredSources) { |
|
| 178 | - $bucketables->each(function ($bucketableData, $bucketable) use ($bucket, &$featuredSources) { |
|
| 177 | + })->each(function($bucketables, $bucket) use (&$featuredSources) { |
|
| 178 | + $bucketables->each(function($bucketableData, $bucketable) use ($bucket, &$featuredSources) { |
|
| 179 | 179 | $featuredSources[$bucketable]['name'] = $bucketableData['name']; |
| 180 | 180 | $featuredSources[$bucketable]['maxPage'] = $bucketableData['items']->lastPage(); |
| 181 | 181 | $featuredSources[$bucketable]['offset'] = $bucketableData['items']->perPage(); |
| 182 | - $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function ($item) use ($bucketableData, $bucketable) { |
|
| 182 | + $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function($item) use ($bucketableData, $bucketable) { |
|
| 183 | 183 | return [ |
| 184 | 184 | 'id' => $item->id, |
| 185 | 185 | 'name' => $item->titleInBucket ?? $item->title, |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function save(Request $request, DB $db) |
| 210 | 210 | { |
| 211 | - $db->transaction(function () use ($request) { |
|
| 212 | - Collection::make($request->get('buckets'))->each(function ($bucketables, $bucketKey) { |
|
| 211 | + $db->transaction(function() use ($request) { |
|
| 212 | + Collection::make($request->get('buckets'))->each(function($bucketables, $bucketKey) { |
|
| 213 | 213 | Feature::where('bucket_key', $bucketKey)->delete(); |
| 214 | 214 | foreach (($bucketables ?? []) as $position => $bucketable) { |
| 215 | 215 | Feature::create([ |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $items = $this->getIndexItems($scopes); |
| 89 | 89 | |
| 90 | 90 | return [ |
| 91 | - 'items' => $items->map(function ($item) { |
|
| 91 | + 'items' => $items->map(function($item) { |
|
| 92 | 92 | return $this->buildFile($item); |
| 93 | 93 | })->toArray(), |
| 94 | 94 | 'maxPage' => $items->lastPage(), |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | private function buildFile($item) |
| 105 | 105 | { |
| 106 | 106 | return $item->toCmsArray() + [ |
| 107 | - 'tags' => $item->tags->map(function ($tag) { |
|
| 107 | + 'tags' => $item->tags->map(function($tag) { |
|
| 108 | 108 | return $tag->name; |
| 109 | 109 | }), |
| 110 | 110 | 'deleteUrl' => $item->canDeleteSafely() ? moduleRoute($this->moduleName, $this->routePrefix, 'destroy', $item->id) : null, |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $items = $this->getIndexItems($scopes); |
| 226 | 226 | |
| 227 | 227 | return $this->responseFactory->json([ |
| 228 | - 'items' => $items->map(function ($item) { |
|
| 228 | + 'items' => $items->map(function($item) { |
|
| 229 | 229 | return $this->buildFile($item); |
| 230 | 230 | })->toArray(), |
| 231 | 231 | 'tags' => $this->repository->getTagsList(), |
@@ -56,16 +56,16 @@ |
||
| 56 | 56 | |
| 57 | 57 | $blocksCollection->push($newBlock); |
| 58 | 58 | |
| 59 | - $block['blocks']->each(function ($childBlock) use ($newBlock, $blocksCollection, $blockRepository) { |
|
| 59 | + $block['blocks']->each(function($childBlock) use ($newBlock, $blocksCollection, $blockRepository) { |
|
| 60 | 60 | $childBlock['parent_id'] = $newBlock->id; |
| 61 | 61 | $newChildBlock = $blockRepository->createForPreview($childBlock); |
| 62 | 62 | $blocksCollection->push($newChildBlock); |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | - $renderedBlocks = $blocksCollection->where('parent_id', null)->map(function ($block) use ($blocksCollection, $viewFactory, $config) { |
|
| 65 | + $renderedBlocks = $blocksCollection->where('parent_id', null)->map(function($block) use ($blocksCollection, $viewFactory, $config) { |
|
| 66 | 66 | if ($config->get('twill.block_editor.block_preview_render_childs') ?? true) { |
| 67 | 67 | $childBlocks = $blocksCollection->where('parent_id', $block->id); |
| 68 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($viewFactory, $config) { |
|
| 68 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($viewFactory, $config) { |
|
| 69 | 69 | $view = $this->getBlockView($childBlock->type, $config); |
| 70 | 70 | |
| 71 | 71 | return $viewFactory->exists($view) ? $viewFactory->make($view, [ |
@@ -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']); |
| 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 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | return []; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $statsByDate = Collection::make($response['rows'] ?? [])->map(function (array $dateRow) { |
|
| 204 | + $statsByDate = Collection::make($response['rows'] ?? [])->map(function(array $dateRow) { |
|
| 205 | 205 | return [ |
| 206 | 206 | 'date' => $dateRow[0], |
| 207 | 207 | 'users' => (int) $dateRow[1], |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | 'yesterday', |
| 217 | 217 | 'week', |
| 218 | 218 | 'month', |
| 219 | - ])->mapWithKeys(function ($period) use ($statsByDate) { |
|
| 219 | + ])->mapWithKeys(function($period) use ($statsByDate) { |
|
| 220 | 220 | $stats = $this->getPeriodStats($period, $statsByDate); |
| 221 | 221 | return [ |
| 222 | 222 | $period => [ |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | 'stats' => $stats = $statsByDate->first(), |
| 254 | 254 | 'moreUsers' => $stats['users'] > $statsByDate->get(1)['users'], |
| 255 | 255 | 'morePageViews' => $stats['pageViews'] > $statsByDate->get(1)['pageViews'], |
| 256 | - 'usersData' => $statsByDate->take(7)->map(function ($stat) { |
|
| 256 | + 'usersData' => $statsByDate->take(7)->map(function($stat) { |
|
| 257 | 257 | return $stat['users']; |
| 258 | 258 | }), |
| 259 | - 'pageViewsData' => $statsByDate->take(7)->map(function ($stat) { |
|
| 259 | + 'pageViewsData' => $statsByDate->take(7)->map(function($stat) { |
|
| 260 | 260 | return $stat['pageViews']; |
| 261 | 261 | }), |
| 262 | 262 | ]; |
@@ -265,10 +265,10 @@ discard block |
||
| 265 | 265 | 'stats' => $stats = $statsByDate->get(1), |
| 266 | 266 | 'moreUsers' => $stats['users'] > $statsByDate->get(2)['users'], |
| 267 | 267 | 'morePageViews' => $stats['pageViews'] > $statsByDate->get(2)['pageViews'], |
| 268 | - 'usersData' => $statsByDate->slice(1)->take(7)->map(function ($stat) { |
|
| 268 | + 'usersData' => $statsByDate->slice(1)->take(7)->map(function($stat) { |
|
| 269 | 269 | return $stat['users']; |
| 270 | 270 | }), |
| 271 | - 'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function ($stat) { |
|
| 271 | + 'pageViewsData' => $statsByDate->slice(1)->take(7)->map(function($stat) { |
|
| 272 | 272 | return $stat['pageViews']; |
| 273 | 273 | }), |
| 274 | 274 | ]; |
@@ -291,10 +291,10 @@ discard block |
||
| 291 | 291 | 'stats' => $stats, |
| 292 | 292 | 'moreUsers' => $stats['users'] > $compareStats['users'], |
| 293 | 293 | 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'], |
| 294 | - 'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 294 | + 'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 295 | 295 | return $stat['users']; |
| 296 | 296 | }), |
| 297 | - 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 297 | + 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 298 | 298 | return $stat['pageViews']; |
| 299 | 299 | }), |
| 300 | 300 | ]; |
@@ -317,10 +317,10 @@ discard block |
||
| 317 | 317 | 'stats' => $stats, |
| 318 | 318 | 'moreUsers' => $stats['users'] > $compareStats['users'], |
| 319 | 319 | 'morePageViews' => $stats['pageViews'] > $compareStats['pageViews'], |
| 320 | - 'usersData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 320 | + 'usersData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 321 | 321 | return $stat['users']; |
| 322 | 322 | }), |
| 323 | - 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function ($stat) { |
|
| 323 | + 'pageViewsData' => $statsByDate->slice(1)->take(29)->map(function($stat) { |
|
| 324 | 324 | return $stat['pageViews']; |
| 325 | 325 | }), |
| 326 | 326 | ]; |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | private function getShortcuts($modules) |
| 348 | 348 | { |
| 349 | - return $modules->filter(function ($module) { |
|
| 349 | + return $modules->filter(function($module) { |
|
| 350 | 350 | return ($module['count'] ?? false) || ($module['create'] ?? false); |
| 351 | - })->map(function ($module) { |
|
| 351 | + })->map(function($module) { |
|
| 352 | 352 | $repository = $this->getRepository($module['name']); |
| 353 | 353 | |
| 354 | 354 | $moduleOptions = [ |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | private function getDrafts($modules) |
| 387 | 387 | { |
| 388 | - return $modules->filter(function ($module) { |
|
| 388 | + return $modules->filter(function($module) { |
|
| 389 | 389 | return ($module['draft'] ?? false); |
| 390 | - })->map(function ($module) { |
|
| 390 | + })->map(function($module) { |
|
| 391 | 391 | $repository = $this->getRepository($module['name']); |
| 392 | 392 | |
| 393 | 393 | $drafts = $repository->draft()->mine()->limit(3)->latest()->get(); |
| 394 | 394 | |
| 395 | - return $drafts->map(function ($draft) use ($module) { |
|
| 395 | + return $drafts->map(function($draft) use ($module) { |
|
| 396 | 396 | return [ |
| 397 | 397 | 'type' => ucfirst($module['label_singular'] ?? Str::singular($module['name'])), |
| 398 | 398 | 'name' => $draft->titleInDashboard ?? $draft->title, |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | // TODO: document this and actually think about moving to queuable job after content type updates |
| 58 | 58 | public function handle() |
| 59 | 59 | { |
| 60 | - $this->db->table('mediables')->orderBy('id')->chunk(100, function ($attached_medias) { |
|
| 60 | + $this->db->table('mediables')->orderBy('id')->chunk(100, function($attached_medias) { |
|
| 61 | 61 | foreach ($attached_medias as $attached_media) { |
| 62 | 62 | $uuid = Media::withTrashed()->find($attached_media->media_id, ['uuid'])->uuid; |
| 63 | 63 | |
@@ -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,15 +45,15 @@ 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 | - $medias = $settings->mapWithKeys(function ($setting) { |
|
| 52 | + $medias = $settings->mapWithKeys(function($setting) { |
|
| 53 | 53 | return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null]; |
| 54 | 54 | })->filter()->toArray(); |
| 55 | 55 | |
| 56 | - return $settings->mapWithKeys(function ($setting) { |
|
| 56 | + return $settings->mapWithKeys(function($setting) { |
|
| 57 | 57 | $settingValue = []; |
| 58 | 58 | |
| 59 | 59 | foreach ($setting->translations as $translation) { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $this->updateOrCreate($section + ['key' => $role], $section + [ |
| 102 | 102 | 'key' => $role, |
| 103 | 103 | 'medias' => [ |
| 104 | - $role => Collection::make($settingsFields['medias'][$role])->map(function ($media) { |
|
| 104 | + $role => Collection::make($settingsFields['medias'][$role])->map(function($media) { |
|
| 105 | 105 | return json_decode($media, true); |
| 106 | 106 | })->values()->filter()->toArray(), |
| 107 | 107 | ], |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $submittedLanguages = Collection::make($fields['languages'] ?? []); |
| 25 | 25 | |
| 26 | - $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) { |
|
| 26 | + $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) { |
|
| 27 | 27 | return $language['published']; |
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | 30 | foreach ($locales as $index => $locale) { |
| 31 | - $submittedLanguage = Arr::first($submittedLanguages->filter(function ($lang) use ($locale) { |
|
| 31 | + $submittedLanguage = Arr::first($submittedLanguages->filter(function($lang) use ($locale) { |
|
| 32 | 32 | return $lang['value'] == $locale; |
| 33 | 33 | })); |
| 34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $fields[$locale] = [ |
| 40 | 40 | 'active' => $activeField, |
| 41 | - ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 41 | + ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 42 | 42 | $attributeValue = $fields[$attribute] ?? null; |
| 43 | 43 | |
| 44 | 44 | // if we are at the last locale, |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | if (property_exists($this->model, 'translatedAttributes')) { |
| 81 | 81 | $attributes = $this->model->translatedAttributes; |
| 82 | - $query->whereHas('translations', function ($q) use ($scopes, $attributes) { |
|
| 82 | + $query->whereHas('translations', function($q) use ($scopes, $attributes) { |
|
| 83 | 83 | foreach ($attributes as $attribute) { |
| 84 | 84 | if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) { |
| 85 | 85 | $q->where($attribute, 'like', '%' . $scopes[$attribute] . '%'); |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
| 72 | 72 | |
| 73 | - $this->getBlocks($object, $fields)->each(function ($block) use ($object, $blockRepository) { |
|
| 73 | + $this->getBlocks($object, $fields)->each(function($block) use ($object, $blockRepository) { |
|
| 74 | 74 | |
| 75 | 75 | $blockCreated = $blockRepository->create($block); |
| 76 | 76 | |
| 77 | - $block['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
| 77 | + $block['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
| 78 | 78 | $childBlock['parent_id'] = $blockCreated->id; |
| 79 | 79 | $blockRepository->create($childBlock); |
| 80 | 80 | }); |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | ]; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
| 176 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
| 177 | 177 | return $key !== "browsers"; |
| 178 | - })->map(function ($value, $key) use ($block) { |
|
| 178 | + })->map(function($value, $key) use ($block) { |
|
| 179 | 179 | return [ |
| 180 | 180 | 'name' => "blocks[$block->id][$key]", |
| 181 | 181 | 'value' => $value, |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | if ($medias) { |
| 190 | 190 | if (config('twill.media_library.translated_form_fields', false)) { |
| 191 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
| 192 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
| 191 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
| 192 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
| 193 | 193 | return [ |
| 194 | 194 | "blocks[$block->id][$key][$locale]" => $value, |
| 195 | 195 | ]; |
| 196 | 196 | }); |
| 197 | 197 | })->filter()->toArray(); |
| 198 | 198 | } else { |
| 199 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
| 199 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
| 200 | 200 | return [ |
| 201 | 201 | "blocks[$block->id][$key]" => $value, |
| 202 | 202 | ]; |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | $files = $blockFormFields['files']; |
| 208 | 208 | |
| 209 | 209 | if ($files) { |
| 210 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 211 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
| 210 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 211 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
| 212 | 212 | return [ |
| 213 | 213 | "blocks[$block->id][$role][$locale]" => $files, |
| 214 | 214 | ]; |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | */ |
| 248 | 248 | protected function getBlockBrowsers($block) |
| 249 | 249 | { |
| 250 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
| 250 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
| 251 | 251 | $relationRepository = $this->getModelRepository($relation); |
| 252 | 252 | $relatedItems = $relationRepository->get([], ['id' => $ids], [], -1); |
| 253 | 253 | $sortedRelatedItems = array_flip($ids); |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | $sortedRelatedItems[$item->id] = $item; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
| 259 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
| 260 | 260 | return is_object($value); |
| 261 | - })->map(function ($relatedElement) use ($relation) { |
|
| 261 | + })->map(function($relatedElement) use ($relation) { |
|
| 262 | 262 | return [ |
| 263 | 263 | 'id' => $relatedElement->id, |
| 264 | 264 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | $mediasCollection = Collection::make(); |
| 24 | 24 | $mediasFromFields = $this->getMedias($fields); |
| 25 | 25 | |
| 26 | - $mediasFromFields->each(function ($media) use ($object, $mediasCollection) { |
|
| 26 | + $mediasFromFields->each(function($media) use ($object, $mediasCollection) { |
|
| 27 | 27 | $newMedia = Media::withTrashed()->find(is_array($media['id']) ? Arr::first($media['id']) : $media['id']); |
| 28 | 28 | $pivot = $newMedia->newPivot($object, Arr::except($media, ['id']), 'mediables', true); |
| 29 | 29 | $newMedia->setRelation('pivot', $pivot); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $object->medias()->sync([]); |
| 50 | 50 | |
| 51 | - $this->getMedias($fields)->each(function ($media) use ($object) { |
|
| 51 | + $this->getMedias($fields)->each(function($media) use ($object) { |
|
| 52 | 52 | $object->medias()->attach($media['id'], Arr::except($media, ['id'])); |
| 53 | 53 | }); |
| 54 | 54 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (in_array($role, array_keys($this->model->mediasParams ?? [])) |
| 78 | 78 | || in_array($role, array_keys(config('twill.block_editor.crops', []))) |
| 79 | 79 | || in_array($role, array_keys(config('twill.settings.crops', [])))) { |
| 80 | - Collection::make($mediasForRole)->each(function ($media) use (&$medias, $role, $locale) { |
|
| 80 | + Collection::make($mediasForRole)->each(function($media) use (&$medias, $role, $locale) { |
|
| 81 | 81 | $customMetadatas = $media['metadatas']['custom'] ?? []; |
| 82 | 82 | if (isset($media['crops']) && !empty($media['crops'])) { |
| 83 | 83 | foreach ($media['crops'] as $cropName => $cropData) { |