35 lines
961 B
PHP
35 lines
961 B
PHP
<?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 {
|
|
if (!$view->offsetExists('profile')) {
|
|
$view->with('profile', \App\Models\RateCardProfile::getSingleton());
|
|
}
|
|
if (!$view->offsetExists('invoiceSettings')) {
|
|
$view->with('invoiceSettings', \App\Models\InvoiceSettings::instance());
|
|
}
|
|
|
|
try {
|
|
$alertCount = Event::upcoming(24)->count();
|
|
} catch (\Throwable) {
|
|
$alertCount = 0;
|
|
}
|
|
$view->with('alertCount', $alertCount);
|
|
});
|
|
}
|
|
}
|