I have the following url
http://project.su/?invitee=95
first i want to check the invitee
in url, if the url have invitee
then get the value.
What i have tried (controller) :
if(!empty($request->get('invitee'))){
$user->invitee = $request->get('invitee');
}
The following code is not working .
I want storing the invitee
result(id) in database.
Thanks.
Laravel routes are located in the app/Http/routes. For instance, to pass in a name parameter to a route, it would look like this. Route::get('/params/{name}', function ($name) { return $name }); By convention, the Controller function accepts parameters based on the parameters provided.
You can pass query string to URL in laravel using named route and controller action. You can pass query string as comma separated array to named route and controller action and redirect to URL.
You can check query string exists or not in laravel blade with comparing the value with null. If query string is not exists in URL then it will return true while using comparision (=) operator.
Using laravel query log we can print the entire query with params as well. In this type of debugging query is executed and we will get the complete parsed query. Here we used DB::enableQueryLog to enable the query log and DB::getQueryLog() to print the all queries in between of it.
To determine if an input value is present:
if ($request->has('invitee')) {
$user->invitee = $request->input('invitee');
}
The has method returns true if the value is present and is not an empty string:
As far as Laravel 5.7 is concerned, the preferred way to retrieve query params is
if( $request->has('invitee') ) {
$request->query('invitee');
}
or using the helper function if you don't have access to $request
request()->query('invitee');
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