For some reason I can't get any GET parameters from a url in my controllers using the Illuminate\Http\Request
facade. I tested in multiple controllers, but no success.
Using the following code, nothing is returned on the remote server when accessing domain.com/admin/dashboard?test=test
, but on my local machine it returns test
:
The dashboard function is called by the route /admin/dashboard
/**
* Dashboard page
*
* @return view
*/
public function dashboard(Request $request)
{
echo '<pre>';
var_dump($request->all());
echo '</pre>';
// Return here
return;
// ...instead of here
return view('backend::pages.dashboard');
}
I'm running Laravel 5.1 on Ubuntu 14.04 LTS using Nginx and php5-fpm. The code works fine on my local Homestead instance as well as on MAMP. I checked my Nginx configuration and everything seems fine. I'm hosting multiple sites on my server and I can get route parameters on all other sites.
If anyone runs into this, the problem was with how I set up Nginx for this particular domain.
This block in my /etc/nginx/sites-enabled/default
file didn't work with query strings:
location / {
try_files $uri $uri/ /index.php$query_string;
}
After changing it to the following, everything worked as it supposed to be:
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
Hope it helps someone.
Try to access it like this:
$var = Input::get('test');
Here is how to do it: Retrieving GET and POST data inside controller in Laravel 4 And also here: What's the best practice accessing $_GET values in Laravel?
Hope helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With