Geoff_S
Geoff_S

Reputation: 5107

grabbing query string param in controller, laravel

I have a form within a blade that calls a controller function and I'm trying to wrap a url query string parameter into the function call.

the url is testsite.com/verifyPhone?accessToken=1Kdfj348fDFJ$($kjdf

In my controller function call I'm already using request for form validation

    $this->validate($request,[
        'verify_phone' => 'required',
    ]);

How can I grab the accessToken parameter in the URL as well and incorporate it into this request to send on my next call like so:

$authService->verifyPhone($request->accessToken, $request->verify_phone);

Upvotes: 0

Views: 1615

Answers (3)

ujiriukiri
ujiriukiri

Reputation: 306

You can also get the query parameter through the Input Facade

Input::get('accessToken')

Make sure to use Illuminate\Support\Facades\Input

Upvotes: 1

Theodoros Alexopoulos
Theodoros Alexopoulos

Reputation: 191

Use

$request->get('accessToken')

instead of

$request->accessToken

Upvotes: 1

user11171256
user11171256

Reputation:

One of the advantages of using Laravel is that you don't need to worry about preventing this kind of attack.

Laravel automatically handles it for each user session. You just need to include @csrf Blade directive in your form.

Documentation: https://laravel.com/docs/5.8/csrf

Upvotes: 1

Related Questions