*/ public function share(Request $request): array { $notifications = Notification::where('entity_type', \App\Models\User::class)->orderBy('created_at', 'desc'); return array_merge(parent::share($request), [ 'auth' => [ 'user' => $request->user() ? $request->user()->load(['role.permissions']) : $request->user(), ], 'flash' => [ 'message' => fn () => $request->session()->get('message'), ], 'app_name' => env('APP_NAME', 'App Name'), 'csrf_token' => csrf_token(), 'notifications' => $notifications->limit(10)->get(), 'count_unread_notifications' => $notifications->where('is_read', Notification::UNREAD)->count(), 'deposit_notifications' => $notifications->where('type', Notification::TYPE_DEPOSIT) ->where('is_read', Notification::UNREAD)->limit(10)->get(), 'stock_notifications' => $notifications->where('type', Notification::TYPE_VOUCHER_STOCK) ->where('is_read', Notification::UNREAD)->limit(10)->get(), ]); } }