57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Prize;
|
|
use App\Models\Settings;
|
|
use Illuminate\Pagination\Paginator;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class ViewServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
if (!app()->runningInConsole()) {
|
|
$appInfos = Cache::remember('composer', 3600, function () {
|
|
return json_decode(File::get(\app_path('../composer.json')));
|
|
});
|
|
View::share('name', $appInfos->name);
|
|
View::share('version', $appInfos->version);
|
|
View::share('license', $appInfos->license);
|
|
// * FORCE BOOTSTRAP PAGINATOR
|
|
Paginator::defaultView('bo.modules.pagination');
|
|
|
|
// 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 = Prize::all();
|
|
Cache::put('prizesGlobal', $prizesGlobal);
|
|
}
|
|
View::share('prizesGlobal', $prizesGlobal);
|
|
|
|
// * CUSTOM IF STATEMENTS
|
|
Blade::if('superadmin', function () {
|
|
return auth()->user() && auth()->user()->role == 1;
|
|
});
|
|
} //end if
|
|
}
|
|
}
|