Skip to content

How to set slug field #451

Answered by loranger
raakkan asked this question in Help
Discussion options

You must be logged in to vote

I had the same problem.

I dug in the discussion and was redirected to the hooks part of the documentation. But in my opinion, sometimes filament documentation is too light to be really helpful.

In your case, you have to override some methods.
I had a Product Model with a slug attribute (generated from the name attribute) for which I needed to create a CRUD, so I created a resource (php artisan make:filament-resource Product).

Inside my app/Filament/Resources/ProductResource/Pages/CreatePorudct.php file, I added the following method:

...

use Illuminate\Support\Str;

class CreateProduct extends CreateRecord
{

...

    public function updatedRecordName($value)
    {
        $slug = Str::slug(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by raakkan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants