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
any suggestion ?
Can you see the notification?
i see just default notification with title
saved
.Did you add these methods in the CreatePage?
I think you have to do a create record modification in the mutateFormDataBeforeCreate() method.
https://filamentphp.com/docs/3.x/panels/resources/creating-records
no i didn’t , its automatically show up after create record.
sorry?
Sorry, I misunderstood, yes, those methods are created on the create page.