I’m currently working on a project in FilamnentPHP v3 and Laravel 11 and I am trying to figure out how to pass the current user_id as a parameter in my AdminPanelProvider to a function in the same class.
My AdminPanelProvider class
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
->login()
->brandName(fn() => auth()->user()->name ?? 'Reporting System')
->brandLogo(asset('logo.png'))
->brandLogoHeight('4rem')
->colors([
'primary' => Color::Red,
])
->sidebarCollapsibleOnDesktop()
->navigationItems(fn()=>auth()->id()) // here is my problem
// rest of Panel function code
.....
}
public static function NavigationReportList($userId)
{
dd($userId,Auth()->id(),fn()=>Auth()->id()); // can't get auth id with the three options
[The dd data that i get when trying to get the auth id][1]
$reports = Report::whereHas('users', function ($query) {
$query->where('users.id', auth()->id());
})
->select('id')
->orderBy('id', 'desc')
->limit(4)
->pluck('id')
->toArray();
// rest of my code
.....
}
So all i want to is to get the auth id inside the static function NavigationReportList
any help will be appreciated