ldc-gen-game-web/app/Providers/AppServiceProvider.php
Jérémy Munsch 9ee2123928
- composer require kwaadpepper/serial-int-caster
- add code parameters into config
- add code length parameter into settings
- add total possible codes to generate in generation page
- add GenerateRequest validation
- changed job ProcessUniqueCode to increase performances using mass insert and pagination
- changed singletoned Settings instance to increase performances
- Fix process export code put datetime in file name
- aded storage to gitignore file
- fixed export to guess export codes, also non recursive now
- changed refactorize a bit EnterCodeController::participate + add request
- Add request to export and generate codes requests
2022-01-07 19:03:25 +01:00

67 lines
1.9 KiB
PHP

<?php
namespace App\Providers;
use App\Models\Prizes;
use App\Models\Settings;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Blade;
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, config('app.locale') . "_" . strtoupper(config('app.locale')) . '.utf8');
app()->singleton(Settings::class, function () {
if (!($settings = Settings::find(1))) {
throw new \ErrorException('Settings not found in DB');
}
return $settings;
});
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 = app(Settings::class)->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);
Blade::if('superadmin', function () {
return auth()->user() && auth()->user()->role == 1;
});
}
}
}