F
Filament10mo ago
EL REKT

Redirect to index after creation

I used modification when creating a record with the handleRecordCreation function, but the function to create notifications and redirect to index doesn't work, is there a proper way to solve this? so far that's what I've done.. protected function handleRecordCreation(array $data): Model { $create = DB::select( 'EXEC create_ticket ?, ?, ?, ?, ?, ?, ?', [ $data['location_id'], $data['priority_id'], $data['type_id'], $data['created_by'], $data['ticket_name'], $data['ticket_desc'], $data['images'], ] ); $id = DB::scalar('SELECT ' . $create[0]->Id); return TicketHeader::find($id); } protected function afterCreate(): void { Notification::make() ->success() ->title('Ticket Created!') ->body('Trouble ticket created successfully.'); } protected function getRedirectUrl(): string { return $this->getResource()::getUrl('index'); }
8 Replies
EL REKT
EL REKTOP10mo ago
any suggestion ?
LeandroFerreira
LeandroFerreira10mo ago
Can you see the notification?
EL REKT
EL REKTOP10mo ago
i see just default notification with title saved.
LeandroFerreira
LeandroFerreira10mo ago
Did you add these methods in the CreatePage?
Sourabh
Sourabh10mo ago
I think you have to do a create record modification in the mutateFormDataBeforeCreate() method. https://filamentphp.com/docs/3.x/panels/resources/creating-records
EL REKT
EL REKTOP10mo ago
no i didn’t , its automatically show up after create record.
LeandroFerreira
LeandroFerreira10mo ago
sorry?
EL REKT
EL REKTOP10mo ago
Sorry, I misunderstood, yes, those methods are created on the create page.
Want results from more Discord servers?
Add your server