In Laravel, if you want to check that a user is logged in or not at the time of application boot, you can use the following code where you can use Auth::guard('college')->check()
to check if a user belongs to guard('college')
guard logged in or not.this can be done in appserviceprovider.php
provider file under the providers folder.
public function boot(): void { view()->composer(['college.*'], function($view){ if(Auth::guard('college')->check()) { $view->with('collegeProfile',collegeProfile::Where('userId', Auth::guard('college')->user()->id)->first()); } }); }
Ravindra is a passionate full stack developer and dedicated blogger with a flair for crafting user-friendly web applications and insightful articles. With expertise spanning front-end and back-end technologies, Ravindra brings ideas to life through innovative coding solutions.