File tree Expand file tree Collapse file tree 5 files changed +43
-22
lines changed Expand file tree Collapse file tree 5 files changed +43
-22
lines changed Original file line number Diff line number Diff line change 1- @if (count (LaravelLocalization:: getSupportedLocales ()) > 1 )
2- @php
3- use \Illuminate\Support\Facades\ Route ;
1+ @php
2+ use Illuminate\Support\Facades\ Route ;
43
5- $page = Route:: current ()-> parameter (' page' );
6- @endphp
4+ $page = Route:: current ()-> parameter (' page' );
5+ @endphp
76
8- <nav class =" relative inline-block text-right" >
9- <div class =" py-1 flex" role =" none" >
10- @foreach (LaravelLocalization:: getSupportedLocales () as $localeCode => $properties )
11- <a href =" {{ $page && is_object ($page ) ? $page -> getViewUrl ($localeCode ) : ' #' } }"
12- class =" text-gray-700 block px-4 py-2 text-sm"
13- role =" menuitem"
14- id =" menu-item-{{ $localeCode } }" >
15- {{ $properties [' native' ] } }
16- </a >
17- @endforeach
18- </div >
19- </nav >
20- @endif
7+ <nav class =" relative inline-block text-right" >
8+ <div class =" py-1 flex" role =" none" >
9+ @foreach (LaravelLocalization:: getSupportedLocales () as $localeCode => $properties )
10+ <a href =" {{ $page && is_object ($page ) ? $page -> getViewUrl ($localeCode ) : ' #' } }"
11+ class =" text-gray-700 block px-4 py-2 text-sm"
12+ role =" menuitem"
13+ id =" menu-item-{{ $localeCode } }" >
14+ {{ $properties [' native' ] } }
15+ </a >
16+ @endforeach
17+ </div >
18+ </nav >
Original file line number Diff line number Diff line change 77
88<x-layouts .base title =" {{ $page -> title } }" wide =" true" >
99 <header >
10- <x-language-switch />
10+ <x-flexible-pages- language-switch />
1111 </header >
1212
1313 <main class =" prose-headings:font-base" >
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function handle(): void
3939 public function seedHomePage (): void
4040 {
4141 $ pageModel = FilamentFlexibleContentBlockPages::config ()->getPageModel ();
42- if (! $ pageModel ::code (Page::HOME_PAGE )->exists ()) {
42+ if (! $ pageModel ::code (Page::HOME_PAGE )->exists ()) {
4343 $ locales = FilamentFlexibleContentBlockPages::config ()->getSupportedLocales ();
4444
4545 $ homePage = new $ pageModel ;
@@ -52,7 +52,7 @@ public function seedHomePage(): void
5252 public function seedSettings (): void
5353 {
5454 $ settingsModel = FilamentFlexibleContentBlockPages::config ()->getSettingsModel ();
55- if ($ settingsModel ::query ()->count () === 0 ) {
55+ if ($ settingsModel ::query ()->count () === 0 ) {
5656 $ locales = FilamentFlexibleContentBlockPages::config ()->getSupportedLocales ();
5757 $ settings = new $ settingsModel ;
5858
Original file line number Diff line number Diff line change 55use Spatie \LaravelPackageTools \Package ;
66use Spatie \LaravelPackageTools \PackageServiceProvider ;
77use Statikbe \FilamentFlexibleContentBlockPages \Commands \SeedDefaultsCommand ;
8+ use Statikbe \FilamentFlexibleContentBlockPages \View \Components \LanguageSwitch ;
89
910class FilamentFlexibleContentBlockPagesServiceProvider extends PackageServiceProvider
1011{
@@ -25,6 +26,9 @@ public function configurePackage(Package $package): void
2526 'create_filament_flexible_content_block_pages_settings_table ' ,
2627 ])
2728 ->hasTranslations ()
28- ->hasCommand (SeedDefaultsCommand::class);
29+ ->hasCommand (SeedDefaultsCommand::class)
30+ ->hasViewComponents ('flexible-pages ' ,
31+ LanguageSwitch::class,
32+ );
2933 }
3034}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Statikbe \FilamentFlexibleContentBlockPages \View \Components ;
4+
5+ use Illuminate \View \Component ;
6+ use Mcamara \LaravelLocalization \Facades \LaravelLocalization ;
7+
8+ class LanguageSwitch extends Component
9+ {
10+ public function render ()
11+ {
12+ return view ('filament-flexible-content-block-pages::components.language-switch ' );
13+ }
14+
15+ public function shouldRender (): bool
16+ {
17+ return count (LaravelLocalization::getSupportedLocales ()) > 1 ;
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments