52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Articles;
|
|
use App\Models\Moments;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\URL;
|
|
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');
|
|
}
|
|
|
|
if (!app()->runningInConsole()) {
|
|
if (!Cache::has('momentFiche')) {
|
|
$momentFiche = Moments::where([['star_moment', 1], ['status', 1]])->first();
|
|
Cache::put('momentFiche', $momentFiche);
|
|
}
|
|
View::share('momentFiche', Cache::get('momentFiche') ?? false);
|
|
|
|
// Liste des actus pour le footer
|
|
$actus = Cache::get('actusGlobal');
|
|
if (!Cache::has('actusGlobal')) {
|
|
$actus = Articles::where([['status', 1], ['category_id', 1]])
|
|
->orderBy('updated_at', 'DESC')->limit(3)->get();
|
|
Cache::put('actusGlobal', $actus);
|
|
}
|
|
View::share('actusGlobal', Cache::get('actusGlobal') ?? false);
|
|
}
|
|
}
|
|
}
|