How can I manipulate the response of a post create
Currently my slug system is generated via:
so if the item name is:
Filamentphp is a package
the slug becomes: filamentphp-is-a-package
What I would like though, is that in the output it sends to the database, he would add the article id and the extension .html so I would like to become: 1574-filamentphp-is-a-package.html
How can I manipulate the response of a post create?Solution:Jump to solution
you set the property slug to your desired value then save it like normal
```
$article = $this->record;
$article->slug = 'slug';
$article->save();...
5 Replies
Ok so I have to use afterCreate, but how do I get the created item id to resave it? with $data['id']? and for save? $data->save()?
try
$this->record
or $this->getRecord()
I was looking at the demo on github because I'm confused anyway about how to act
https://github.com/filamentphp/demo/blob/f2a27fd03ba8a8d2c2b1287d6b3949a456e47be7/app/Filament/Resources/Shop/OrderResource/Pages/CreateOrder.php#L21
could you give me some examples?
GitHub
demo/app/Filament/Resources/Shop/OrderResource/Pages/CreateOrder.ph...
Source code for the demo.filamentphp.com website. Contribute to filamentphp/demo development by creating an account on GitHub.
Solution
you set the property slug to your desired value then save it like normal