fix: add exception handling to ViewServiceProvider boot method to prevent application crashes on database errors
This commit is contained in:
parent
09d70d052b
commit
3f8ca0c6d9
@ -25,28 +25,31 @@ public function register(): void
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
if (Schema::hasTable('settings')) {
|
try {
|
||||||
view()->share('general', app(GeneralSettings::class));
|
if (Schema::hasTable('settings')) {
|
||||||
view()->share('social', app(SocialMediaSettings::class));
|
view()->share('general', app(GeneralSettings::class));
|
||||||
view()->share('seo', app(SeoSettings::class));
|
view()->share('social', app(SocialMediaSettings::class));
|
||||||
|
view()->share('seo', app(SeoSettings::class));
|
||||||
|
|
||||||
view()->composer('components.partials.footer', function ($view) {
|
view()->composer('components.partials.footer', function ($view) {
|
||||||
$routeStatisticModel = config('route-statistics.model', Visitor::class);
|
$routeStatisticModel = config('route-statistics.model', Visitor::class);
|
||||||
|
|
||||||
$today = $routeStatisticModel::whereDate('date', Carbon::today())->sum('counter');
|
$today = $routeStatisticModel::whereDate('date', Carbon::today())->sum('counter');
|
||||||
$yesterday = $routeStatisticModel::whereDate('date', Carbon::yesterday())->sum('counter');
|
$yesterday = $routeStatisticModel::whereDate('date', Carbon::yesterday())->sum('counter');
|
||||||
$thisMonth = $routeStatisticModel::whereMonth('date', Carbon::now()->month)
|
$thisMonth = $routeStatisticModel::whereMonth('date', Carbon::now()->month)
|
||||||
->whereYear('date', Carbon::now()->year)
|
->whereYear('date', Carbon::now()->year)
|
||||||
->sum('counter');
|
->sum('counter');
|
||||||
$total = $routeStatisticModel::sum('counter');
|
$total = $routeStatisticModel::sum('counter');
|
||||||
|
|
||||||
$view->with('visitorStats', [
|
$view->with('visitorStats', [
|
||||||
'today' => number_format($today),
|
'today' => number_format($today),
|
||||||
'yesterday' => number_format($yesterday),
|
'yesterday' => number_format($yesterday),
|
||||||
'thisMonth' => number_format($thisMonth),
|
'thisMonth' => number_format($thisMonth),
|
||||||
'total' => number_format($total),
|
'total' => number_format($total),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} catch (\Throwable $th) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user