© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Guatashi

Create multiple records at once (pseudo code)

I have a form with 3 fields.
1 field is inside a repeater and the other 2 are not, as they are common to all records.
If the user enters 10 repeaters, 10 records will be persisted.

What I did to make it work is customize the creation process inside my create page class:

protected function handleRecordCreation(array $data): Model
{
    // pseudo code
    foreach (myrepeater as repeater)
    {
        $models[] = static::getModel()::create($repeater_and_common_data)
    }

    // just to be compliance with the return type
    return $models[0];
}
protected function handleRecordCreation(array $data): Model
{
    // pseudo code
    foreach (myrepeater as repeater)
    {
        $models[] = static::getModel()::create($repeater_and_common_data)
    }

    // just to be compliance with the return type
    return $models[0];
}


My question is: Is this the way to go or does this code smell bad?
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

Create multiple records at once
FilamentFFilament / ❓┊help
3y ago
Create multiple records when click createAction
FilamentFFilament / ❓┊help
2y ago
Storing multiple filenames at once when uploading multiple files
FilamentFFilament / ❓┊help
11mo ago
How to input multiple rows at once?
FilamentFFilament / ❓┊help
2y ago