Filament Import Fails , Using `Admin` Model instead of `User`

--> Full Issue description in the text file in comments Brief: What I am trying to do: - Import a CSV into a Filament resource via ImportAction (queued ImportCsv job), updating existing DailyGift rows by day. What I did: - Implemented a Filament Importer with columns (day, amount, coin_id). - resolveRecord() returns the DailyGift by day or throws RowImportFailedException if missing. - imports row is created with user_id = 1. - Admin panel uses the admin guard. App\Models\Admin::find(1) returns a model; App\Models\User::find(1) is null. - Queue driver: database; using queue:work. My issue/the error: - The ImportCsv job keeps failing and retrying with: Illuminate\Auth\SessionGuard::login(): Argument #1 ($user) must be of type Authenticatable, null given - Stack shows Filament tries to log in the initiating user, but it resolves to null at runtime. This suggests the job authenticates via the default web/users provider instead of the admin/admins provider, so retrieveById(1) returns null. I can’t globally switch the default guard (other jobs rely on it).
Solution:
After some research i have solved this problem using : ```php // AppServiceProvider use Illuminate\Support\Facades\Route; ...
Jump to solution
11 Replies
Dennis Koch
Dennis Koch2mo ago
Why did you repeat your description in the .txt file? That makes it harder to read. Also it would help with syntax highlighting
Mahmoud Elshiha
Mahmoud ElshihaOP2mo ago
thanks , i edited the .txt file
Dennis Koch
Dennis Koch2mo ago
Next time, please just post the code here too. You can use markdown and Discord will highlight it. I think what you need to do is bind the Admin model to the Authenticatable. Put this into a service provider: $this->app->bind(Authenticatable::class, Admin::class);
Dennis Koch
Dennis Koch2mo ago
GitHub
Implementing AUTH_MODEL for Import & Export Enhancement · filament...
Today I was confused when using the database on QUEUE_CONNECTION Import & Export Job always failed, after I investigated because \App\Models\User was not found. FYI: I'm using \App\Domains...
Mahmoud Elshiha
Mahmoud ElshihaOP2mo ago
thanx, i will keep that in mind and for the
$this->app->bind(Authenticatable::class, Admin::class);
$this->app->bind(Authenticatable::class, Admin::class);
i have already done that and it still getting me the same error
Dennis Koch
Dennis Koch2mo ago
Did you restart the queue?
Mahmoud Elshiha
Mahmoud ElshihaOP2mo ago
yeah i have restarted the queue and the server also
php artisan optimize:clear
php artisan optimize:clear
to be sure no cache or anything
Dennis Koch
Dennis Koch2mo ago
Is this local or in production? Could it be OpCache?
Mahmoud Elshiha
Mahmoud ElshihaOP2mo ago
this is on local and no i don't think it is OpCache problem neither
Solution
Mahmoud Elshiha
Mahmoud Elshiha2mo ago
After some research i have solved this problem using :
// AppServiceProvider
use Illuminate\Support\Facades\Route;

public function boot(): void
{
Route::middlewareGroup('filament.actions', [
'web',
'auth:admin',
]);
}
// AppServiceProvider
use Illuminate\Support\Facades\Route;

public function boot(): void
{
Route::middlewareGroup('filament.actions', [
'web',
'auth:admin',
]);
}
Also i was incorrectly importing Authenticatable at
use Illuminate\Contracts\Auth\Authenticatable; // <- this is the Right Import

public function register(): void
{
$this->app->bind(Authenticatable::class, Admin::class);
}
use Illuminate\Contracts\Auth\Authenticatable; // <- this is the Right Import

public function register(): void
{
$this->app->bind(Authenticatable::class, Admin::class);
}

Did you find this page helpful?