I am sending request via query parameters in laravel but this error is very uncommon to me as i have never seen this before what it actually does is it adds ?in very first key like this
array:1 [▼
"?name" => "google"
]
while hitting this url
http://travel.localhost/home?name=google
dd($_GET);
dd(request()->all());
dd(request()-get('name'));
i have done all these method but for first two lines i am getting ?name =
and for third line i am getting null as i am looking for name but request is ?name
as per my knowledge we use GET request frequently and bind required parameters in query parameter like ?param1=¶m2=¶m3 ... and so on
so please anyone having any idea why this error occured or is anything wrong in my project
is this can be related to server as i am doing this on nginx but when i am using serve method
and serving my project on localhost:8000 then this problem is not there
any help
Thank you!!
To get request paramters either its POST or GET use the request()
helper for it.
Example:
URL: http://travel.localhost/home?name=google
Use request()->get('name');
Result will be google
this can be used for post parameters as well.
If you want to get all the request paramters
Use request()->all()
Result will be
[
'name' => 'google'
]
Also check your app\Http\Kernel.php
file and see if you're missing any middleware mentioned in below picture.