`Auth::user()` is null in Onboarding Manager Pro
In several projects we where fighting about the reason for the
Auth::user() being null in ServiceProviders. We bought the plugin OnBoarding Manager Pro and every time we would check that the user was logged in or trying to get related collection to the logged in user it says
auth()->user() is null or
Auth::user() is null.
Suddenly we found out that we could use the below solution and that worked in all projects.
And also in the schemas for the onboarding steps we would use the below.
Step::make("Choose department")->icon('heroicon-o-user-group')->statePath('department_id')->schema([Select::make('department_id')->label('Choose department')->options(fn() => Department::where('customer_id', Auth::user()->customer->id)->pluck('name', 'id'))->placeholder('Choose department')->disablePlaceholderSelection()->searchable(),]),