© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
Fonz

Import: Column not found: 1054 Unknown column 'grade' in 'field list'

Hi,

I have an import action in a relationship manager, with the following fields:
            ImportColumn::make('name')
                ->requiredMapping()
                ->rules(['required', 'max:255']),
            ImportColumn::make('grade')
                ->rules(['max:255']),
            ImportColumn::make('birthday')
                ->rules(['date']),
            ImportColumn::make('name')
                ->requiredMapping()
                ->rules(['required', 'max:255']),
            ImportColumn::make('grade')
                ->rules(['max:255']),
            ImportColumn::make('birthday')
                ->rules(['date']),

Then in resolveRecord(), I check if the record exists (firstOrCreate) and attach to its parent. The value from grade should be saved in the pivot table.

        $particpant = Participant::firstOrCreate([
            'name' => $this->data['name'],
        ]);
        $grade = $this->data['grade'] ?? null;
        $particpant->certificats()->syncWithoutDetaching($this->options['certificatID'], ['grade' => $grade]);
    
        return $particpant;
        $particpant = Participant::firstOrCreate([
            'name' => $this->data['name'],
        ]);
        $grade = $this->data['grade'] ?? null;
        $particpant->certificats()->syncWithoutDetaching($this->options['certificatID'], ['grade' => $grade]);
    
        return $particpant;

If I import name and birthday only, everything works as expected. But as soon as I add grade, I get the following error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'grade' in 'field list' (Connection: mysql, SQL: update `participants` set `grade` = 10, `participants`.`updated_at` = 2024-03-21 21:02:46 where `id` = 10963)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'grade' in 'field list' (Connection: mysql, SQL: update `participants` set `grade` = 10, `participants`.`updated_at` = 2024-03-21 21:02:46 where `id` = 10963)


The script tries to add the grade to the participant table when creating a new participant, which does not exist. How to tell it to ignore "grade" when creating a new participant?

I tried setting 'birthday' a second parameter, in hope it would then only consider name and birthday. But it does not.

Is this even the right way to handle this import action?
Thanks
Solution
I solved it by adding an empty ->fillRecordUsing(function (Participant $participant, string $state) {
})
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'shipment_items.organization_id' in 'where cl
FilamentFFilament / ❓┊help
2y ago
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'personal_access_tokens.company_id' in 'where
FilamentFFilament / ❓┊help
3y ago
Import Action - "unknown column '' in `where clause` "
FilamentFFilament / ❓┊help
16mo ago