@lizzie
In Laravel, you can get the post id using the post link by following these steps:
- First, make sure you have defined the route for the post in your routes/web.php file. For example, if you have a route like this:
1
|
Route::get('/posts/{id}', 'PostController@show')->name('posts.show');
|
- To get the post id from the post link, you can use Laravel's built-in helper function route() along with the route name and pass the post id as a parameter. For example:
1
|
$postId = route('posts.show', ['id' => $postId])->parameter('id');
|
This will return the post id based on the post link provided.
- You can then use this $postId variable to retrieve the post details from the database or perform any other operation you want to do with the post id.