initial commit
This commit is contained in:
27
app/Providers/AppServiceProvider.php
Normal file
27
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void {}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
// Inject alert badge count into all views
|
||||
View::composer('*', function (\Illuminate\View\View $view): void {
|
||||
try {
|
||||
$alertCount = Event::upcoming(24)->count();
|
||||
} catch (\Throwable) {
|
||||
$alertCount = 0;
|
||||
}
|
||||
$view->with('alertCount', $alertCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user