@@ -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); |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | public function findByName($search, $sources = []) |
| 51 | 51 | { |
| 52 | 52 | return $this->collect() |
| 53 | - ->filter(function ($block) use ($search, $sources) { |
|
| 53 | + ->filter(function($block) use ($search, $sources) { |
|
| 54 | 54 | return $block->name == $search && |
| 55 | 55 | (blank($sources) || |
| 56 | 56 | collect($sources)->contains($block->source)); |
| 57 | 57 | }) |
| 58 | - ->sortBy(function ($block) { |
|
| 58 | + ->sortBy(function($block) { |
|
| 59 | 59 | return $block->source === 'app' ? 0 : 1; |
| 60 | 60 | }) |
| 61 | 61 | ->first(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | public function getBlocks() |
| 68 | 68 | { |
| 69 | 69 | return $this->collect() |
| 70 | - ->filter(function ($block) { |
|
| 70 | + ->filter(function($block) { |
|
| 71 | 71 | return $block->type === Block::TYPE_BLOCK; |
| 72 | 72 | }) |
| 73 | 73 | ->values(); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function getBlockList() |
| 80 | 80 | { |
| 81 | - return $this->getBlocks()->map(function (Block $block) { |
|
| 81 | + return $this->getBlocks()->map(function(Block $block) { |
|
| 82 | 82 | return $block->toList(); |
| 83 | 83 | }); |
| 84 | 84 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | return collect(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - return collect($this->fileSystem->files($directory))->map(function ( |
|
| 108 | + return collect($this->fileSystem->files($directory))->map(function( |
|
| 109 | 109 | $file |
| 110 | 110 | ) use ($source, $type) { |
| 111 | 111 | return new Block($file, $type, $source); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $this->paths = collect( |
| 121 | 121 | config('twill.block_editor.directories.source.blocks') |
| 122 | 122 | ) |
| 123 | - ->map(function ($path) { |
|
| 123 | + ->map(function($path) { |
|
| 124 | 124 | $path['type'] = Block::TYPE_BLOCK; |
| 125 | 125 | |
| 126 | 126 | return $path; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | ->merge( |
| 129 | 129 | collect( |
| 130 | 130 | config('twill.block_editor.directories.source.repeaters') |
| 131 | - )->map(function ($path) { |
|
| 131 | + )->map(function($path) { |
|
| 132 | 132 | $path['type'] = Block::TYPE_REPEATER; |
| 133 | 133 | |
| 134 | 134 | return $path; |
@@ -166,12 +166,12 @@ discard block |
||
| 166 | 166 | $this->generatePaths(); |
| 167 | 167 | |
| 168 | 168 | $this->items = collect($this->paths) |
| 169 | - ->reduce(function (Collection $keep, $path) { |
|
| 169 | + ->reduce(function(Collection $keep, $path) { |
|
| 170 | 170 | $this->readBlocks( |
| 171 | 171 | $path['path'], |
| 172 | 172 | $path['source'], |
| 173 | 173 | $path['type'] |
| 174 | - )->each(function ($block) use ($keep) { |
|
| 174 | + )->each(function($block) use ($keep) { |
|
| 175 | 175 | $keep->push($block); |
| 176 | 176 | |
| 177 | 177 | return $keep; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | ->toArray(); |
| 183 | 183 | |
| 184 | 184 | $this->items = $this->collect() |
| 185 | - ->each(function (Block $block) { |
|
| 185 | + ->each(function(Block $block) { |
|
| 186 | 186 | $block->setSource($this->detectCustomSources($block)); |
| 187 | 187 | }) |
| 188 | 188 | ->toArray(); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function list() |
| 205 | 205 | { |
| 206 | - return $this->collect()->map(function (Block $block) { |
|
| 206 | + return $this->collect()->map(function(Block $block) { |
|
| 207 | 207 | return $block->toList(); |
| 208 | 208 | }); |
| 209 | 209 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | public function getRepeaters() |
| 223 | 223 | { |
| 224 | 224 | return $this->collect() |
| 225 | - ->filter(function ($block) { |
|
| 225 | + ->filter(function($block) { |
|
| 226 | 226 | return $block->type === Block::TYPE_REPEATER; |
| 227 | 227 | }) |
| 228 | 228 | ->values(); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function getRepeaterList() |
| 235 | 235 | { |
| 236 | - return $this->getRepeaters()->map(function (Block $block) { |
|
| 236 | + return $this->getRepeaters()->map(function(Block $block) { |
|
| 237 | 237 | return $block->toList(); |
| 238 | 238 | }); |
| 239 | 239 | } |
@@ -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 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | "$this->viewPrefix.index", |
| 332 | 332 | "twill::$this->moduleName.index", |
| 333 | 333 | "twill::layouts.listing", |
| 334 | - ])->first(function ($view) { |
|
| 334 | + ])->first(function($view) { |
|
| 335 | 335 | return View::exists($view); |
| 336 | 336 | }); |
| 337 | 337 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | "$this->viewPrefix.form", |
| 443 | 443 | "twill::$this->moduleName.form", |
| 444 | 444 | "twill::layouts.form", |
| 445 | - ])->first(function ($view) { |
|
| 445 | + ])->first(function($view) { |
|
| 446 | 446 | return View::exists($view); |
| 447 | 447 | }); |
| 448 | 448 | |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | "$this->viewPrefix.form", |
| 470 | 470 | "twill::$this->moduleName.form", |
| 471 | 471 | "twill::layouts.form", |
| 472 | - ])->first(function ($view) { |
|
| 472 | + ])->first(function($view) { |
|
| 473 | 473 | return View::exists($view); |
| 474 | 474 | }); |
| 475 | 475 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | "$this->viewPrefix.form", |
| 593 | 593 | "twill::$this->moduleName.form", |
| 594 | 594 | "twill::layouts.form", |
| 595 | - ])->first(function ($view) { |
|
| 595 | + ])->first(function($view) { |
|
| 596 | 596 | return View::exists($view); |
| 597 | 597 | }); |
| 598 | 598 | |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | $query = $this->request->input('q'); |
| 840 | 840 | $tags = $this->repository->getTags($query); |
| 841 | 841 | |
| 842 | - return Response::json(['items' => $tags->map(function ($tag) { |
|
| 842 | + return Response::json(['items' => $tags->map(function($tag) { |
|
| 843 | 843 | return $tag->name; |
| 844 | 844 | })], 200); |
| 845 | 845 | } |
@@ -927,8 +927,8 @@ discard block |
||
| 927 | 927 | protected function getIndexTableData($items) |
| 928 | 928 | { |
| 929 | 929 | $translated = $this->moduleHas('translations'); |
| 930 | - return $items->map(function ($item) use ($translated) { |
|
| 931 | - $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function ($column) use ($item) { |
|
| 930 | + return $items->map(function($item) use ($translated) { |
|
| 931 | + $columnsData = Collection::make($this->indexColumns)->mapWithKeys(function($column) use ($item) { |
|
| 932 | 932 | return $this->getItemColumnData($item, $column); |
| 933 | 933 | })->toArray(); |
| 934 | 934 | |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | 'feature', |
| 1189 | 1189 | 'bulkFeature', |
| 1190 | 1190 | 'bulkDelete', |
| 1191 | - ])->mapWithKeys(function ($endpoint) { |
|
| 1191 | + ])->mapWithKeys(function($endpoint) { |
|
| 1192 | 1192 | return [ |
| 1193 | 1193 | $endpoint . 'Url' => $this->getIndexOption($endpoint) ? moduleRoute( |
| 1194 | 1194 | $this->moduleName, $this->routePrefix, $endpoint, |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | */ |
| 1205 | 1205 | protected function getIndexOption($option) |
| 1206 | 1206 | { |
| 1207 | - return once(function () use ($option) { |
|
| 1207 | + return once(function() use ($option) { |
|
| 1208 | 1208 | $customOptionNamesMapping = [ |
| 1209 | 1209 | 'store' => 'create', |
| 1210 | 1210 | ]; |
@@ -1261,8 +1261,8 @@ discard block |
||
| 1261 | 1261 | { |
| 1262 | 1262 | $withImage = $this->moduleHas('medias'); |
| 1263 | 1263 | |
| 1264 | - return $items->map(function ($item) use ($withImage) { |
|
| 1265 | - $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function ($column) use ($item) { |
|
| 1264 | + return $items->map(function($item) use ($withImage) { |
|
| 1265 | + $columnsData = Collection::make($this->browserColumns)->mapWithKeys(function($column) use ($item) { |
|
| 1266 | 1266 | return $this->getItemColumnData($item, $column); |
| 1267 | 1267 | })->toArray(); |
| 1268 | 1268 | |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | $fieldSplitted = explode('|', $field); |
| 1329 | 1329 | if (count($fieldSplitted) > 1) { |
| 1330 | 1330 | $requestValue = $requestFilters[$key]; |
| 1331 | - Collection::make($fieldSplitted)->each(function ($scopeKey) use (&$scope, $requestValue) { |
|
| 1331 | + Collection::make($fieldSplitted)->each(function($scopeKey) use (&$scope, $requestValue) { |
|
| 1332 | 1332 | $scope[$scopeKey] = $requestValue; |
| 1333 | 1333 | }); |
| 1334 | 1334 | } else { |
@@ -1505,11 +1505,11 @@ discard block |
||
| 1505 | 1505 | */ |
| 1506 | 1506 | protected function validateFormRequest() |
| 1507 | 1507 | { |
| 1508 | - $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function ($permission, $field) { |
|
| 1508 | + $unauthorizedFields = Collection::make($this->fieldsPermissions)->filter(function($permission, $field) { |
|
| 1509 | 1509 | return Auth::guard('twill_users')->user()->cannot($permission); |
| 1510 | 1510 | })->keys(); |
| 1511 | 1511 | |
| 1512 | - $unauthorizedFields->each(function ($field) { |
|
| 1512 | + $unauthorizedFields->each(function($field) { |
|
| 1513 | 1513 | $this->request->offsetUnset($field); |
| 1514 | 1514 | }); |
| 1515 | 1515 | |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | */ |
| 1756 | 1756 | public function getRepeaterList() |
| 1757 | 1757 | { |
| 1758 | - return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function ($repeater) { |
|
| 1758 | + return app(BlockCollection::class)->getRepeaterList()->mapWithKeys(function($repeater) { |
|
| 1759 | 1759 | return [$repeater['name'] => $repeater]; |
| 1760 | 1760 | }); |
| 1761 | 1761 | } |