diff --git a/src/FilamentLanguageSwitchServiceProvider.php b/src/FilamentLanguageSwitchServiceProvider.php index 7d2b72b..0d643c1 100644 --- a/src/FilamentLanguageSwitchServiceProvider.php +++ b/src/FilamentLanguageSwitchServiceProvider.php @@ -2,17 +2,16 @@ namespace BezhanSalleh\FilamentLanguageSwitch; -use Filament\Panel; -use Livewire\Livewire; +use BezhanSalleh\FilamentLanguageSwitch\Http\Livewire\FilamentLanguageSwitch; +use BezhanSalleh\FilamentLanguageSwitch\Http\Middleware\SwitchLanguageLocale; use Filament\Facades\Filament; +use Filament\Http\Middleware\DispatchServingFilamentEvent; +use Filament\Panel; use Filament\Support\Assets\Css; -use Spatie\LaravelPackageTools\Package; use Filament\Support\Facades\FilamentAsset; +use Livewire\Livewire; +use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; -use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch; -use Filament\Http\Middleware\DispatchServingFilamentEvent; -use BezhanSalleh\FilamentLanguageSwitch\Http\Livewire\FilamentLanguageSwitch; -use BezhanSalleh\FilamentLanguageSwitch\Http\Middleware\SwitchLanguageLocale; class FilamentLanguageSwitchServiceProvider extends PackageServiceProvider { @@ -72,4 +71,4 @@ protected function reorderCurrentPanelMiddlewareStack(Panel $panel): void ->concat($middlewareCollection->slice($position)) ->toArray(); } -} \ No newline at end of file +} diff --git a/src/Http/Livewire/FilamentLanguageSwitch.php b/src/Http/Livewire/FilamentLanguageSwitch.php index 89b6f0e..713bec2 100644 --- a/src/Http/Livewire/FilamentLanguageSwitch.php +++ b/src/Http/Livewire/FilamentLanguageSwitch.php @@ -2,9 +2,9 @@ namespace BezhanSalleh\FilamentLanguageSwitch\Http\Livewire; -use Livewire\Component; -use Illuminate\Contracts\View\View; use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch; +use Illuminate\Contracts\View\View; +use Livewire\Component; class FilamentLanguageSwitch extends Component { @@ -23,7 +23,7 @@ public function changeLocale($locale) public function render(): View { return view('filament-language-switch::language-switch', [ - 'languageSwitch' => LanguageSwitch::make() + 'languageSwitch' => LanguageSwitch::make(), ]); } } diff --git a/src/Http/Middleware/SwitchLanguageLocale.php b/src/Http/Middleware/SwitchLanguageLocale.php index 4c3f79f..d20050b 100644 --- a/src/Http/Middleware/SwitchLanguageLocale.php +++ b/src/Http/Middleware/SwitchLanguageLocale.php @@ -2,13 +2,13 @@ namespace BezhanSalleh\FilamentLanguageSwitch\Http\Middleware; +use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch; use Closure; use Illuminate\Http\Request; -use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch; class SwitchLanguageLocale { - public function handle(Request $request, Closure $next): \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + public function handle(Request $request, Closure $next): \Illuminate\Http\Response | \Illuminate\Http\RedirectResponse { $locale = session()->get('locale') ?? $request->get('locale') diff --git a/src/LanguageSwitch.php b/src/LanguageSwitch.php index 3c67686..a28d6d6 100755 --- a/src/LanguageSwitch.php +++ b/src/LanguageSwitch.php @@ -7,8 +7,8 @@ use Closure; use Filament\Panel; use Filament\Support\Concerns; -use Illuminate\Support\Facades\Blade; use Filament\Support\Facades\FilamentView; +use Illuminate\Support\Facades\Blade; class LanguageSwitch { @@ -17,7 +17,7 @@ class LanguageSwitch protected bool | Closure $isCircular = false; - protected null | string $displayLocale = null; + protected ?string $displayLocale = null; protected array | Closure $excludes = []; @@ -122,7 +122,7 @@ public function getFlags(): array { $flagUrls = (array) $this->evaluate($this->flags); - foreach($flagUrls as $url) { + foreach ($flagUrls as $url) { if (! filter_var($url, FILTER_VALIDATE_URL)) { throw new \Exception('Invlid flag url'); exit; @@ -181,4 +181,4 @@ public function getLabel(string $locale): string { return $this->labels[$locale] ?? locale_get_display_name($locale, $this->getDisplayLocale()); } -} \ No newline at end of file +}