I have PostResource
in my filament application.
Post modal schema
Posts
- id
- title
- slug
- description
- created_by
- status
Now, whenever I create a new post and it redirects to the Edit page and URL accessing like http://127.0.0.1"8000/posts/1/edit
.
but can we add a slug in the URL?
Excepted URL: http://127.0.0.1"8000/posts/<SLUG>/edit
In my PostResource
the routes
public static function getPages(): array
{
return [
'index' => PagesListPosts::route('/'),
'create' => PagesCreatePost::route('/create'),
// here, it binding route model, I want to change with slug
'edit' => PagesEditPost::route('/{record}/edit'),
];
}
2
Answers
You should read basic Laravel documentation
It’s simple, is that…
In your
PostResource
you need to add->url()
and as a route parameter add$record->slug
.