0

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);
3
  • $request->get('accessToken') doesnt work? Commented Mar 13, 2019 at 15:46
  • 1
    shoot, I was using $request()->accessToken Commented Mar 13, 2019 at 15:46
  • i updated it as an answer Commented Mar 13, 2019 at 15:53

3 Answers 3

1

You can also get the query parameter through the Input Facade

Input::get('accessToken')

Make sure to use Illuminate\Support\Facades\Input

Sign up to request clarification or add additional context in comments.

Comments

1

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

3 Comments

I'm not sure I understand? this has nothing to do with csrf, I'm getting a token from an internal API that is used for a feature registration. I just want to make sure I"m passing the url parameter called accessToken in this function call
I believe it's necessary to expect the question mark in your web.php route file. Something like Route::get('/verifyPhone?accessToken={accessToken}'...
The param is there, but I'm not getting it at the route. Just in the controller. I'm just looking for something like request()->param
1

Use

$request->get('accessToken')

instead of

$request->accessToken

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.