ldc-gen-game-web/app/Providers/AppServiceProvider.php

61 lines
1.7 KiB
PHP
Raw Normal View History

2020-10-21 15:26:21 +02:00
<?php
namespace App\Providers;
use App\Models\Prizes;
2020-10-29 15:40:23 +01:00
use App\Models\Settings;
use Illuminate\Support\Facades\Cache;
2020-10-29 15:40:23 +01:00
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Blade;
2020-10-21 15:26:21 +02:00
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
2021-08-18 17:08:02 +02:00
if (config('app.env') !== 'local') {
2020-11-05 12:41:00 +01:00
\URL::forceScheme('https');
}
2021-05-28 10:13:24 +02:00
setlocale(LC_TIME, config('app.locale') . "_" . strtoupper(config('app.locale')) . '.utf8');
2020-11-05 12:36:18 +01:00
if (!app()->runningInConsole()) {
// On ramène le nom du jeu et le nom de la société sur toute les pages
$settingsGlobal = Cache::get('settingsGlobal');
if (!$settingsGlobal) {
$settingsGlobal = Settings::find(1)->select('name', 'company', 'analytics', 'start_date', 'end_date')->first();
Cache::put('settingsGlobal', $settingsGlobal);
}
2020-11-05 12:36:18 +01:00
View::share('settingsGlobal', $settingsGlobal);
// On ramène aussi tout les prix car on en a besoin sur le header
$prizesGlobal = Cache::get('prizesGlobal');
if (!$prizesGlobal) {
$prizesGlobal = Prizes::all();
Cache::put('prizesGlobal', $prizesGlobal);
}
View::share('prizesGlobal', $prizesGlobal);
Blade::if('superadmin', function () {
return auth()->user() && auth()->user()->role == 1;
});
2020-11-05 12:36:18 +01:00
}
2020-10-21 15:26:21 +02:00
}
}