Custom import job

Getting a serializable error when trying to import using a custom job:

Cannot initialize readonly property Filament\Actions\Imports\Jobs\ImportCsv::$importer from scope App\Jobs\ImportPatients
(attached error message)

I am tryin to import patients, patients is a model that needs Users model to exists, where patient belongs to user

I have managed to create an import action, but that does not create the user with the patient, so I am resorting to creating an importer with a custom job
$table->headerActions([ ImportAction::make() ->importer(PatientImporter::class) ->job(ImportPatients::class) ])

I can't figure out what's wrong, and there is no duocumentation on this.
Solution
if you want to create the relationship(user) along with the patient record, make use of the beforeSave hook
protected function beforeSave(): void
    {
//
}
Was this page helpful?