@@ -38,7 +38,7 @@ |
||
| 38 | 38 | public function getAncestorsSlug($locale = null) |
| 39 | 39 | { |
| 40 | 40 | return collect($this->ancestors ?? []) |
| 41 | - ->map(function ($i) use ($locale) { return $i->getSlug($locale); }) |
|
| 41 | + ->map(function($i) use ($locale) { return $i->getSlug($locale); }) |
|
| 42 | 42 | ->implode('/'); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | 'hasPosition', |
| 208 | 208 | 'hasRevisions', |
| 209 | 209 | 'hasNesting', |
| 210 | - ])->filter(function ($enabled) { |
|
| 210 | + ])->filter(function($enabled) { |
|
| 211 | 211 | return $enabled; |
| 212 | 212 | }); |
| 213 | 213 | |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | $start = "{$delimiters[0]}{$key}{$delimiters[1]}"; |
| 832 | 832 | $end = "{$delimiters[0]}\/{$key}{$delimiters[1]}"; |
| 833 | 833 | |
| 834 | - if ((bool)$value) { |
|
| 834 | + if ((bool) $value) { |
|
| 835 | 835 | // replace delimiters only |
| 836 | 836 | $stub = preg_replace("/$start/", '', $stub); |
| 837 | 837 | $stub = preg_replace("/$end/", '', $stub); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | public function registerCapsules() |
| 46 | 46 | { |
| 47 | - $this->manager->getCapsuleList()->map(function ($capsule) { |
|
| 47 | + $this->manager->getCapsuleList()->map(function($capsule) { |
|
| 48 | 48 | $this->registerCapsule($capsule); |
| 49 | 49 | }); |
| 50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | if (!self::$capsulesBootstrapped) { |
| 60 | 60 | $this->getCapsuleList() |
| 61 | 61 | ->where('enabled', true) |
| 62 | - ->each(function ($capsule) { |
|
| 62 | + ->each(function($capsule) { |
|
| 63 | 63 | $this->bootstrapCapsule($capsule); |
| 64 | 64 | }); |
| 65 | 65 | self::$capsulesBootstrapped = true; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function registerViewPaths() |
| 76 | 76 | { |
| 77 | 77 | if (file_exists(config('twill.capsules.path'))) { |
| 78 | - $callback = function ($view) { |
|
| 78 | + $callback = function($view) { |
|
| 79 | 79 | $view->addLocation(config('twill.capsules.path')); |
| 80 | 80 | }; |
| 81 | 81 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | if (!config('twill.capsules.loaded')) { |
| 24 | 24 | $list = $list |
| 25 | 25 | ->where('enabled', true) |
| 26 | - ->map(function ($capsule) use ($path) { |
|
| 26 | + ->map(function($capsule) use ($path) { |
|
| 27 | 27 | return $this->makeCapsule($capsule, $path); |
| 28 | 28 | }); |
| 29 | 29 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function getCapsuleByModule($module) |
| 42 | 42 | { |
| 43 | 43 | return $this->getCapsuleList() |
| 44 | - ->filter(function ($capsule) use ($module) { |
|
| 44 | + ->filter(function($capsule) use ($module) { |
|
| 45 | 45 | return Str::lower($capsule['plural']) == Str::lower($module); |
| 46 | 46 | }) |
| 47 | 47 | ->first(); |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | { |
| 265 | 265 | $twillSeeder = app(CapsuleSeeder::class); |
| 266 | 266 | |
| 267 | - $this->getCapsuleList()->each(function ($capsule) use ( |
|
| 267 | + $this->getCapsuleList()->each(function($capsule) use ( |
|
| 268 | 268 | $twillSeeder, |
| 269 | 269 | $illuminateSeeder |
| 270 | 270 | ) { |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | return; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - collect($files)->each(function ($file) { |
|
| 378 | + collect($files)->each(function($file) { |
|
| 379 | 379 | if (file_exists($file)) { |
| 380 | 380 | require_once $file; |
| 381 | 381 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $this->modelName = $this->locateModel($this->argument('modelName')); |
| 100 | 100 | |
| 101 | - if (! $this->modelName) { |
|
| 101 | + if (!$this->modelName) { |
|
| 102 | 102 | $this->error("Model `{$this->argument('modelName')}` was not found`"); |
| 103 | 103 | |
| 104 | 104 | return 1; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $mediasParams = app($this->modelName)->mediasParams; |
| 110 | 110 | |
| 111 | - if (! isset($mediasParams[$this->roleName])) { |
|
| 111 | + if (!isset($mediasParams[$this->roleName])) { |
|
| 112 | 112 | $this->error("Role `{$this->roleName}` was not found`"); |
| 113 | 113 | |
| 114 | 114 | return 1; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function byKey($key, $section = null) |
| 36 | 36 | { |
| 37 | - $settingQuery = $this->model->when($section, function ($query) use ($section) { |
|
| 37 | + $settingQuery = $this->model->when($section, function($query) use ($section) { |
|
| 38 | 38 | $query->where('section', $section); |
| 39 | 39 | })->where('key', $key); |
| 40 | 40 | |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function getFormFields($section = null) |
| 53 | 53 | { |
| 54 | - $settings = $this->model->when($section, function ($query) use ($section) { |
|
| 54 | + $settings = $this->model->when($section, function($query) use ($section) { |
|
| 55 | 55 | $query->where('section', $section); |
| 56 | 56 | })->with('translations', 'medias')->get(); |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | if (config('twill.media_library.translated_form_fields', false)) { |
| 60 | - $medias = $settings->reduce(function ($carry, $setting) { |
|
| 60 | + $medias = $settings->reduce(function($carry, $setting) { |
|
| 61 | 61 | foreach (getLocales() as $locale) { |
| 62 | 62 | if (!empty(parent::getFormFields($setting)['medias'][$locale]) && !empty(parent::getFormFields($setting)['medias'][$locale][$setting->key])) |
| 63 | 63 | { |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | return $carry; |
| 68 | 68 | }); |
| 69 | 69 | } else { |
| 70 | - $medias = $settings->mapWithKeys(function ($setting) { |
|
| 70 | + $medias = $settings->mapWithKeys(function($setting) { |
|
| 71 | 71 | return [$setting->key => parent::getFormFields($setting)['medias'][$setting->key] ?? null]; |
| 72 | 72 | })->filter()->toArray(); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - return $settings->mapWithKeys(function ($setting) { |
|
| 75 | + return $settings->mapWithKeys(function($setting) { |
|
| 76 | 76 | $settingValue = []; |
| 77 | 77 | |
| 78 | 78 | foreach ($setting->translations as $translation) { |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (config('twill.media_library.translated_form_fields', false)) { |
| 125 | 125 | foreach (getLocales() as $locale) { |
| 126 | - $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function ($media) { |
|
| 126 | + $medias["{$role}[{$locale}]"] = Collection::make($settingsFields['medias'][$role][$locale])->map(function($media) { |
|
| 127 | 127 | return json_decode($media, true); |
| 128 | 128 | })->filter()->toArray(); |
| 129 | 129 | } |
| 130 | 130 | } else { |
| 131 | - $medias = [ |
|
| 132 | - $role => Collection::make($settingsFields['medias'][$role])->map(function ($media) { |
|
| 131 | + $medias = [ |
|
| 132 | + $role => Collection::make($settingsFields['medias'][$role])->map(function($media) { |
|
| 133 | 133 | return json_decode($media, true); |
| 134 | 134 | })->values()->filter()->toArray(), |
| 135 | 135 | ]; |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | $submittedLanguages = Collection::make($fields['languages'] ?? []); |
| 34 | 34 | |
| 35 | - $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function ($language) { |
|
| 35 | + $atLeastOneLanguageIsPublished = $submittedLanguages->contains(function($language) { |
|
| 36 | 36 | return $language['published']; |
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | 39 | foreach ($locales as $index => $locale) { |
| 40 | - $submittedLanguage = Arr::first($submittedLanguages->filter(function ($lang) use ($locale) { |
|
| 40 | + $submittedLanguage = Arr::first($submittedLanguages->filter(function($lang) use ($locale) { |
|
| 41 | 41 | return $lang['value'] == $locale; |
| 42 | 42 | })); |
| 43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $fields[$locale] = [ |
| 49 | 49 | 'active' => $activeField, |
| 50 | - ] + $attributes->mapWithKeys(function ($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 50 | + ] + $attributes->mapWithKeys(function($attribute) use (&$fields, $locale, $localesCount, $index) { |
|
| 51 | 51 | $attributeValue = $fields[$attribute] ?? null; |
| 52 | 52 | |
| 53 | 53 | // if we are at the last locale, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | if ($this->model->isTranslatable()) { |
| 108 | 108 | $attributes = $this->model->translatedAttributes; |
| 109 | - $query->whereHas('translations', function ($q) use ($scopes, $attributes) { |
|
| 109 | + $query->whereHas('translations', function($q) use ($scopes, $attributes) { |
|
| 110 | 110 | foreach ($attributes as $attribute) { |
| 111 | 111 | if (isset($scopes[$attribute]) && is_string($scopes[$attribute])) { |
| 112 | 112 | $q->where($attribute, $this->getLikeOperator(), '%' . $scopes[$attribute] . '%'); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $blockRepository->bulkDelete($object->blocks()->pluck('id')->toArray()); |
| 108 | - $this->getBlocks($object, $fields)->each(function ($block) use ($blockRepository) { |
|
| 108 | + $this->getBlocks($object, $fields)->each(function($block) use ($blockRepository) { |
|
| 109 | 109 | $this->createBlock($blockRepository, $block); |
| 110 | 110 | }); |
| 111 | 111 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $blockCreated = $blockRepository->create($blockFields); |
| 123 | 123 | |
| 124 | 124 | // Handle child blocks |
| 125 | - $blockFields['blocks']->each(function ($childBlock) use ($blockCreated, $blockRepository) { |
|
| 125 | + $blockFields['blocks']->each(function($childBlock) use ($blockCreated, $blockRepository) { |
|
| 126 | 126 | $childBlock['parent_id'] = $blockCreated->id; |
| 127 | 127 | $this->createBlock($blockRepository, $childBlock); |
| 128 | 128 | }); |
@@ -237,9 +237,9 @@ discard block |
||
| 237 | 237 | ]; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $fields['blocksFields'][] = Collection::make($block['content'])->filter(function ($value, $key) { |
|
| 240 | + $fields['blocksFields'][] = Collection::make($block['content'])->filter(function($value, $key) { |
|
| 241 | 241 | return $key !== "browsers"; |
| 242 | - })->map(function ($value, $key) use ($block) { |
|
| 242 | + })->map(function($value, $key) use ($block) { |
|
| 243 | 243 | return [ |
| 244 | 244 | 'name' => "blocks[$block->id][$key]", |
| 245 | 245 | 'value' => $value, |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | if ($medias) { |
| 254 | 254 | if (config('twill.media_library.translated_form_fields', false)) { |
| 255 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($mediasByLocale, $locale) use ($block) { |
|
| 256 | - return Collection::make($mediasByLocale)->mapWithKeys(function ($value, $key) use ($block, $locale) { |
|
| 255 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($mediasByLocale, $locale) use ($block) { |
|
| 256 | + return Collection::make($mediasByLocale)->mapWithKeys(function($value, $key) use ($block, $locale) { |
|
| 257 | 257 | return [ |
| 258 | 258 | "blocks[$block->id][$key][$locale]" => $value, |
| 259 | 259 | ]; |
| 260 | 260 | }); |
| 261 | 261 | })->filter()->toArray(); |
| 262 | 262 | } else { |
| 263 | - $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function ($value, $key) use ($block) { |
|
| 263 | + $fields['blocksMedias'][] = Collection::make($medias)->mapWithKeys(function($value, $key) use ($block) { |
|
| 264 | 264 | return [ |
| 265 | 265 | "blocks[$block->id][$key]" => $value, |
| 266 | 266 | ]; |
@@ -271,8 +271,8 @@ discard block |
||
| 271 | 271 | $files = $blockFormFields['files']; |
| 272 | 272 | |
| 273 | 273 | if ($files) { |
| 274 | - Collection::make($files)->each(function ($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 275 | - $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $block) { |
|
| 274 | + Collection::make($files)->each(function($rolesWithFiles, $locale) use (&$fields, $block) { |
|
| 275 | + $fields['blocksFiles'][] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $block) { |
|
| 276 | 276 | return [ |
| 277 | 277 | "blocks[$block->id][$role][$locale]" => $files, |
| 278 | 278 | ]; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | protected function getBlockBrowsers($block) |
| 313 | 313 | { |
| 314 | - return Collection::make($block['content']['browsers'])->mapWithKeys(function ($ids, $relation) use ($block) { |
|
| 314 | + return Collection::make($block['content']['browsers'])->mapWithKeys(function($ids, $relation) use ($block) { |
|
| 315 | 315 | if (Schema::hasTable(config('twill.related_table', 'twill_related')) && $block->getRelated($relation)->isNotEmpty()) { |
| 316 | 316 | $items = $this->getFormFieldsForRelatedBrowser($block, $relation); |
| 317 | 317 | foreach ($items as &$item) { |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | $sortedRelatedItems[$item->id] = $item; |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - $items = Collection::make(array_values($sortedRelatedItems))->filter(function ($value) { |
|
| 345 | + $items = Collection::make(array_values($sortedRelatedItems))->filter(function($value) { |
|
| 346 | 346 | return is_object($value); |
| 347 | - })->map(function ($relatedElement) use ($relation) { |
|
| 347 | + })->map(function($relatedElement) use ($relation) { |
|
| 348 | 348 | return [ |
| 349 | 349 | 'id' => $relatedElement->id, |
| 350 | 350 | 'name' => $relatedElement->titleInBrowser ?? $relatedElement->title, |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 48 | 48 | $relatedItems = Collection::make(); |
| 49 | 49 | |
| 50 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use (&$relatedItems) { |
|
| 51 | - Collection::make($items)->each(function ($item) use ($browserName, &$relatedItems) { |
|
| 50 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use (&$relatedItems) { |
|
| 51 | + Collection::make($items)->each(function($item) use ($browserName, &$relatedItems) { |
|
| 52 | 52 | try { |
| 53 | 53 | $repository = $this->getModelRepository($item['endpointType'] ?? $browserName); |
| 54 | 54 | $relatedItems->push((object) [ |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | if (Schema::hasTable(config('twill.related_table', 'twill_related'))) { |
| 78 | 78 | if (isset($fields['browsers'])) { |
| 79 | - Collection::make($fields['browsers'])->each(function ($items, $browserName) use ($object) { |
|
| 79 | + Collection::make($fields['browsers'])->each(function($items, $browserName) use ($object) { |
|
| 80 | 80 | $object->saveRelated($items, $browserName); |
| 81 | 81 | }); |
| 82 | 82 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $block['content'] = empty($block['content']) ? new \stdClass : (object) $block['content']; |
| 110 | 110 | |
| 111 | 111 | if ($block['browsers']) { |
| 112 | - $browsers = Collection::make($block['browsers'])->map(function ($items) { |
|
| 112 | + $browsers = Collection::make($block['browsers'])->map(function($items) { |
|
| 113 | 113 | return Collection::make($items)->pluck('id'); |
| 114 | 114 | })->toArray(); |
| 115 | 115 | |