To redirect to the list page after creating or updating a resource in Filament v3, you can use a custom trait in your resource class .
Create a Custom Trait
<?php
namespace App\Traits;
trait RedirectIndex
{
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
Use the Trait in Your Filament Resource
class CreateProduct extends CreateRecord
{
protected static string $resource = ProductResource::class;
//add trait in your CreateRecord or UpdateRecord
use \App\Traits\RedirectIndex;
}
Top comments (1)
Excelente