ldc-gen-game-web/app/Providers/AppServiceProvider.php
Olivier Legat 4ebf21ab12 Gestion du cache des dates du jeu
Gestion de la locale des dates
2021-05-28 09:38:51 +02:00

57 lines
1.6 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Prizes;
use App\Models\Settings;
use Illuminate\Queue\Events\JobProcessed;
use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\View;
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()
{
if(config('app.env') !== 'local') {
\URL::forceScheme('https');
}
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
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);
}
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);
}
}
}