-
category model has name field and slug field. this slug generate from name field. please help anyone. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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. Inside my ...
use Illuminate\Support\Str;
class CreateProduct extends CreateRecord
{
...
public function updatedRecordName($value)
{
$slug = Str::slug($value);
$this->record['sku'] = $slug;
} I didn't need to make this sku attribute editable, I only needed to generate this slug on creation. I hope it would help ! |
Beta Was this translation helpful? Give feedback.
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: