© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
10 replies
Krishzzi

get_class(): Argument #1 ($object) must be of type object, null given Filament::auth()

I have a common resource for multiple users (User model, Artist Model, Affiliate Model) etc.

in the list page, in table query I have like this.. to only load logged in user specific records
public function table(Table $table): Table
    {
        return $table
            ->modifyQueryUsing(fn ($query) => $query->published()->forUserType(get_class(Filament::auth()->user()));
}
public function table(Table $table): Table
    {
        return $table
            ->modifyQueryUsing(fn ($query) => $query->published()->forUserType(get_class(Filament::auth()->user()));
}

here we basicaly call where user_type = current auth user class

this works fine ..
but in test , when I do
$this->get(HelpModuleResource::getUrl('index'))->assertSuccessful();
$this->get(HelpModuleResource::getUrl('index'))->assertSuccessful();

I also add beforeEach for my pest test
beforeEach(function () {
    $this->actingAs(Artist::factory()->create(), 'artist');
    $this->actingAs(User::factory()->create(), 'web');
// other users
});
beforeEach(function () {
    $this->actingAs(Artist::factory()->create(), 'artist');
    $this->actingAs(User::factory()->create(), 'web');
// other users
});

I try to do this too chain with actingAs()->startSession() but still same error


I get this error : get_class(): Argument #1 ($object) must be of type object, null given

why Filament::auth()->user() is null while user actingAs and how to fix this..
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

foreach() argument must be of type array|object, null given
FilamentFFilament / ❓┊help
2y ago
Filament\Pages\BasePage::getInfolist(): Argument #1 ($name) must be of type string, null given
FilamentFFilament / ❓┊help
3y ago
Argument #1 ($form) must be of type Filament\Forms\Form, Filament\Infolists\Infolist given
FilamentFFilament / ❓┊help
4mo ago
Argument #1 ($values) must be of type array, string given
FilamentFFilament / ❓┊help
3y ago