@@ -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'], |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | private function getFeaturedItemsByBucket($featuredSection, $featuredSectionKey) |
| 101 | 101 | { |
| 102 | 102 | $bucketRouteConfig = $this->config->get('twill.bucketsRoutes') ?? [$featuredSectionKey => 'featured']; |
| 103 | - return Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) { |
|
| 103 | + return Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use ($featuredSectionKey, $bucketRouteConfig) { |
|
| 104 | 104 | $routePrefix = $bucketRouteConfig[$featuredSectionKey]; |
| 105 | 105 | return [ |
| 106 | 106 | 'id' => $bucketKey, |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | 'acceptedSources' => Collection::make($bucket['bucketables'])->pluck('module'), |
| 110 | 110 | 'withToggleFeatured' => $bucket['with_starred_items'] ?? false, |
| 111 | 111 | 'toggleFeaturedLabels' => $bucket['starred_items_labels'] ?? [], |
| 112 | - 'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function ($feature) use ($bucket) { |
|
| 112 | + 'children' => Feature::where('bucket_key', $bucketKey)->with('featured')->get()->map(function($feature) use ($bucket) { |
|
| 113 | 113 | if (($item = $feature->featured) != null) { |
| 114 | 114 | $forModuleRepository = collect($bucket['bucketables'])->where('module', $feature->featured_type)->first()['repository'] ?? null; |
| 115 | 115 | $repository = $this->getRepository($feature->featured_type, $forModuleRepository); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | 'thumbnail' => $item->defaultCmsImage(['w' => 100, 'h' => 100]), |
| 129 | 129 | ] : []); |
| 130 | 130 | } |
| 131 | - })->reject(function ($item) { |
|
| 131 | + })->reject(function($item) { |
|
| 132 | 132 | return is_null($item); |
| 133 | 133 | })->values()->toArray(), |
| 134 | 134 | ]; |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | $fetchedModules = []; |
| 147 | 147 | $featuredSources = []; |
| 148 | 148 | |
| 149 | - Collection::make($featuredSection['buckets'])->map(function ($bucket, $bucketKey) use (&$fetchedModules, $search, $request) { |
|
| 150 | - return Collection::make($bucket['bucketables'])->mapWithKeys(function ($bucketable) use (&$fetchedModules, $search, $request) { |
|
| 149 | + Collection::make($featuredSection['buckets'])->map(function($bucket, $bucketKey) use (&$fetchedModules, $search, $request) { |
|
| 150 | + return Collection::make($bucket['bucketables'])->mapWithKeys(function($bucketable) use (&$fetchedModules, $search, $request) { |
|
| 151 | 151 | |
| 152 | 152 | $module = $bucketable['module']; |
| 153 | 153 | $repository = $this->getRepository($module, $bucketable['repository'] ?? null); |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | 'withImage' => $withImage, |
| 177 | 177 | ]]; |
| 178 | 178 | }); |
| 179 | - })->each(function ($bucketables, $bucket) use (&$featuredSources) { |
|
| 180 | - $bucketables->each(function ($bucketableData, $bucketable) use (&$featuredSources) { |
|
| 179 | + })->each(function($bucketables, $bucket) use (&$featuredSources) { |
|
| 180 | + $bucketables->each(function($bucketableData, $bucketable) use (&$featuredSources) { |
|
| 181 | 181 | $featuredSources[$bucketable]['name'] = $bucketableData['name']; |
| 182 | 182 | $featuredSources[$bucketable]['maxPage'] = $bucketableData['items']->lastPage(); |
| 183 | 183 | $featuredSources[$bucketable]['offset'] = $bucketableData['items']->perPage(); |
| 184 | - $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function ($item) use ($bucketableData, $bucketable) { |
|
| 184 | + $featuredSources[$bucketable]['items'] = $bucketableData['items']->map(function($item) use ($bucketableData, $bucketable) { |
|
| 185 | 185 | return [ |
| 186 | 186 | 'id' => $item->id, |
| 187 | 187 | 'name' => $item->titleInBucket ?? $item->title, |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function save(Request $request, DB $db) |
| 212 | 212 | { |
| 213 | - $db->transaction(function () use ($request) { |
|
| 214 | - Collection::make($request->get('buckets'))->each(function ($bucketables, $bucketKey) { |
|
| 213 | + $db->transaction(function() use ($request) { |
|
| 214 | + Collection::make($request->get('buckets'))->each(function($bucketables, $bucketKey) { |
|
| 215 | 215 | Feature::where('bucket_key', $bucketKey)->delete(); |
| 216 | 216 | foreach (($bucketables ?? []) as $position => $bucketable) { |
| 217 | 217 | Feature::create([ |
@@ -16,23 +16,23 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | public function boot() |
| 18 | 18 | { |
| 19 | - Validator::extend('absolute_or_relative_url', function ($attribute, $value, $parameters, $validator) { |
|
| 19 | + Validator::extend('absolute_or_relative_url', function($attribute, $value, $parameters, $validator) { |
|
| 20 | 20 | return Str::startsWith($value, '/') || Validator::make([$attribute => $value], [$attribute => 'url'])->passes(); |
| 21 | 21 | }, 'The :attribute should be a valid url (absolute or relative)'); |
| 22 | 22 | |
| 23 | - Validator::extend('relative_or_secure_url', function ($attribute, $value, $parameters) { |
|
| 23 | + Validator::extend('relative_or_secure_url', function($attribute, $value, $parameters) { |
|
| 24 | 24 | return Str::startsWith($value, '/') || filter_var($value, FILTER_VALIDATE_URL) !== false && Str::startsWith($value, 'https'); |
| 25 | 25 | }, 'The :attribute should be a valid url (relative or https)'); |
| 26 | 26 | |
| 27 | - Validator::extend('web_color', function ($attribute, $value, $parameters, $validator) { |
|
| 27 | + Validator::extend('web_color', function($attribute, $value, $parameters, $validator) { |
|
| 28 | 28 | return preg_match('/^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i', $value); |
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | - Validator::extend('phone_number', function ($attribute, $value, $parameters) { |
|
| 31 | + Validator::extend('phone_number', function($attribute, $value, $parameters) { |
|
| 32 | 32 | return preg_match("/^[+]?[0-9\-\ ]*$/", $value); |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | - Validator::extend('validBlocks', function ($attribute, $value, $parameters, $validator) { |
|
| 35 | + Validator::extend('validBlocks', function($attribute, $value, $parameters, $validator) { |
|
| 36 | 36 | $blockMessages = []; |
| 37 | 37 | |
| 38 | 38 | foreach ($value as $block) { |
@@ -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 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $this->getChildrenPreview($block['blocks'], $blocksCollection, $newBlock->id, $blockId, $blockRepository); |
| 53 | 53 | |
| 54 | - $renderedBlocks = $blocksCollection->where('parent_id', null)->map(function ($block) use ($blocksCollection, $viewFactory, $config) { |
|
| 54 | + $renderedBlocks = $blocksCollection->where('parent_id', null)->map(function($block) use ($blocksCollection, $viewFactory, $config) { |
|
| 55 | 55 | if ($config->get('twill.block_editor.block_preview_render_childs') ?? true) { |
| 56 | 56 | $childBlocks = $blocksCollection->where('parent_id', $block->id); |
| 57 | - $renderedChildViews = $childBlocks->map(function ($childBlock) use ($viewFactory, $config) { |
|
| 57 | + $renderedChildViews = $childBlocks->map(function($childBlock) use ($viewFactory, $config) { |
|
| 58 | 58 | $view = $this->getBlockView($childBlock->type, $config); |
| 59 | 59 | |
| 60 | 60 | return $viewFactory->exists($view) ? $viewFactory->make($view, [ |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | protected function getChildrenPreview($blocks, $blocksCollection, $parentId, &$blockId, $blockRepository) |
| 110 | 110 | { |
| 111 | - $blocks->each(function ($childBlock) use (&$blockId, $parentId, $blocksCollection, $blockRepository) { |
|
| 111 | + $blocks->each(function($childBlock) use (&$blockId, $parentId, $blocksCollection, $blockRepository) { |
|
| 112 | 112 | $childBlock['parent_id'] = $parentId; |
| 113 | 113 | $blockId++; |
| 114 | 114 | $newChildBlock = $blockRepository->createForPreview($childBlock); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | return DB::table(config('twill.fileables_table', 'twill_fileables'))->where('file_id', $this->id)->count() === 0; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function scopeUnused ($query) |
|
| 28 | + public function scopeUnused($query) |
|
| 29 | 29 | { |
| 30 | 30 | $usedIds = DB::table(config('twill.fileables_table'))->get()->pluck('file_id'); |
| 31 | 31 | return $query->whereNotIn('id', $usedIds->toArray())->get(); |
@@ -20,12 +20,12 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $icons = collect( |
| 22 | 22 | config('twill.block_editor.directories.source.icons') |
| 23 | - )->reduce(function (Collection $keep, $path) { |
|
| 23 | + )->reduce(function(Collection $keep, $path) { |
|
| 24 | 24 | if (!$this->files->exists($path)) { |
| 25 | 25 | return $keep; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $files = collect($this->files->files($path))->map(function ( |
|
| 28 | + $files = collect($this->files->files($path))->map(function( |
|
| 29 | 29 | SplFileInfo $file |
| 30 | 30 | ) { |
| 31 | 31 | if (in_array($file->getFilename(), config('twill.internal_icons'))) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | abort(404); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return response()->stream(function () use ($file) { |
|
| 57 | + return response()->stream(function() use ($file) { |
|
| 58 | 58 | echo $this->files->get($file); |
| 59 | 59 | }, 200, ["Content-Type" => "image/svg+xml"]); |
| 60 | 60 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $this->blockCollection |
| 49 | 49 | ->getMissingDirectories() |
| 50 | - ->each(function ($directory) { |
|
| 50 | + ->each(function($directory) { |
|
| 51 | 51 | $this->error("Directory not found: {$directory}"); |
| 52 | 52 | }); |
| 53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | return $blockCollection |
| 62 | 62 | ->first() |
| 63 | 63 | ->keys() |
| 64 | - ->map(function ($key) { |
|
| 64 | + ->map(function($key) { |
|
| 65 | 65 | return Str::studly($key); |
| 66 | 66 | }) |
| 67 | 67 | ->toArray(); |
@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | return $this->blockCollection |
| 83 | 83 | ->collect() |
| 84 | - ->reject(function (Block $block) use ($sourceFiltered) { |
|
| 84 | + ->reject(function(Block $block) use ($sourceFiltered) { |
|
| 85 | 85 | return $sourceFiltered && !$this->option($block->source); |
| 86 | 86 | }) |
| 87 | - ->reject(function (Block $block) use ($typeFiltered) { |
|
| 87 | + ->reject(function(Block $block) use ($typeFiltered) { |
|
| 88 | 88 | return $this->dontPassTextFilter($block) || |
| 89 | 89 | ($typeFiltered && |
| 90 | 90 | !$this->option(Str::plural($block->type))); |
| 91 | 91 | }) |
| 92 | - ->map(function (Block $block) { |
|
| 92 | + ->map(function(Block $block) { |
|
| 93 | 93 | return $this->colorize( |
| 94 | 94 | $this->option('short') ? $block->toShortList() : $block->toList() |
| 95 | 95 | ); |
| 96 | 96 | }) |
| 97 | - ->sortBy(function ($block) { |
|
| 97 | + ->sortBy(function($block) { |
|
| 98 | 98 | return [$block['group'], $block['title']]; |
| 99 | 99 | }); |
| 100 | 100 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | if (filled($filter = $this->argument('filter'))) { |
| 153 | 153 | return !$block |
| 154 | 154 | ->toList() |
| 155 | - ->reduce(function ($keep, $element) use ($filter) { |
|
| 155 | + ->reduce(function($keep, $element) use ($filter) { |
|
| 156 | 156 | return $keep || |
| 157 | 157 | Str::contains( |
| 158 | 158 | Str::lower($element), |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | return collect( |
| 355 | 355 | config('twill.block_editor.directories.source.icons') |
| 356 | - )->reduce(function ($keep, $path) use ($icon) { |
|
| 356 | + )->reduce(function($keep, $path) use ($icon) { |
|
| 357 | 357 | if ($keep) { |
| 358 | 358 | return $keep; |
| 359 | 359 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | return null; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - return collect($this->files->files($path))->reduce(function ($keep, SplFileInfo $file) use ($icon) { |
|
| 365 | + return collect($this->files->files($path))->reduce(function($keep, SplFileInfo $file) use ($icon) { |
|
| 366 | 366 | if ($keep) { |
| 367 | 367 | return $keep; |
| 368 | 368 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 47 | 47 | $relatedItems = Collection::make(); |
| 48 | 48 | |
| 49 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use (&$relatedItems) { |
|
| 50 | - Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) { |
|
| 49 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use (&$relatedItems) { |
|
| 50 | + Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) { |
|
| 51 | 51 | try { |
| 52 | 52 | $repository = $this->getModelRepository($item['endpointType'] ?? $browserName); |
| 53 | 53 | $relatedItems->push((object) [ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 77 | 77 | if (isset($fields['browsers'])) { |
| 78 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) { |
|
| 78 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) { |
|
| 79 | 79 | $object->saveRelated($items, $browserName); |
| 80 | 80 | }); |
| 81 | 81 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | $blocksList = app(BlockCollection::class)->getBlockList(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $block['type'] = $blocksList->keyBy('name')->search(function ($blockConfig) use ($block) { |
|
| 110 | + $block['type'] = $blocksList->keyBy('name')->search(function($blockConfig) use ($block) { |
|
| 111 | 111 | return $blockConfig['component'] === $block['type']; |
| 112 | 112 | }); |
| 113 | 113 | |
| 114 | 114 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
| 115 | 115 | |
| 116 | 116 | if ($block['browsers']) { |
| 117 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
| 117 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
| 118 | 118 | return Collection::make($items)->pluck('id'); |
| 119 | 119 | })->toArray(); |
| 120 | 120 | |