mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use BezhanSalleh\LanguageSwitch\LanguageSwitch;
|
|
use Illuminate\Support\Facades\Event;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use SocialiteProviders\Manager\SocialiteWasCalled;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
Gate::before(function ($user): null | bool {
|
|
if (method_exists($user, 'hasRole') && $user->hasRole('admin')) {
|
|
return true;
|
|
}
|
|
|
|
return null;
|
|
});
|
|
|
|
View::addNamespace('app', resource_path('views'));
|
|
|
|
Event::listen(function (SocialiteWasCalled $event): void {
|
|
$event->extendSocialite('apple', \SocialiteProviders\Apple\Provider::class);
|
|
});
|
|
|
|
$availableLocales = config('app.available_locales', ['en']);
|
|
$localeLabels = [
|
|
'en' => 'English',
|
|
'tr' => 'Turkish',
|
|
];
|
|
|
|
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) use ($availableLocales, $localeLabels): void {
|
|
$switch
|
|
->locales($availableLocales)
|
|
->labels(collect($availableLocales)->mapWithKeys(
|
|
fn (string $locale) => [$locale => $localeLabels[$locale] ?? strtoupper($locale)]
|
|
)->all())
|
|
->visible(insidePanels: count($availableLocales) > 1, outsidePanels: false);
|
|
});
|
|
}
|
|
}
|