© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
4 replies
The Huntsman

Mutate Before Create Function

    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $data['date_issued'] = date(now());
        return $data;
        $amount = $data['stock_issued'];
        $stock = 10;
        if ($amount > $stock) {
            Notification::make()
                ->warning()
                ->title('You don\'t have enough Stock!!!')
                ->body('Only ' . $stock . ' in inventory.')
                ->send();
            $this->halt();
        }
    }
    protected function mutateFormDataBeforeCreate(array $data): array
    {
        $data['date_issued'] = date(now());
        return $data;
        $amount = $data['stock_issued'];
        $stock = 10;
        if ($amount > $stock) {
            Notification::make()
                ->warning()
                ->title('You don\'t have enough Stock!!!')
                ->body('Only ' . $stock . ' in inventory.')
                ->send();
            $this->halt();
        }
    }


Can anyone please tell me what's wrong here, I don't get any errors but it doesn't work, and I tried to use the
beforeCreate()
beforeCreate()
Function but that doesn't let me pass the
$data
$data
array.
Solution
What's not working? Can you be more specific? You have return on second line so everything later won't be executed
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Mutate Data before Create (calculated column)
FilamentFFilament / ❓┊help
2y ago
Mutate form data before create but for delete
FilamentFFilament / ❓┊help
3y ago
Mutate ManageRelatedRecords data before saving
FilamentFFilament / ❓┊help
2y ago
mutate relation data before saving
FilamentFFilament / ❓┊help
3y ago