paboo's avatar
Level 1

get id from url in laravel

i have relearn laravel but i have issue in php if i want get id in url its

$id=GET[id] if i want to get id on url like php in laravel how do i do that
thanks bros
0 likes
6 replies
nafeeur10's avatar
Level 5

xyz.com/id

$request->id;

You can get id from POST method like this.

In PHP:

$id = $_POST['id'];
2 likes
paboo's avatar
Level 1

Like this bros

 public function getDetail(Requests $rq){
    $product = Product::where('id',$rq->id)->get(); 

}
.
1 like
tykus's avatar

You should typehint Request i.e. Illuminate\Http\Request, not Requests.

This is assuming the id is in the query string, and not in the route wildcard.

3 likes

Please or to participate in this conversation.