Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hidayat3676's avatar

how to get only query data from url

i have a url like localhost/posts/id here id is query which is an integer value how can i get this from this url

0 likes
1 reply
rin4ik's avatar

little example

Route::get('/posts/{id}',Controller@method);

controller

public function method($id)
{
$post = Post::find($id);
return view('post.show', compact('post'))
}

view

{{ $post->title}}

Please or to participate in this conversation.