Home > database >  Redirect using get and then redirect to the response
Redirect using get and then redirect to the response

Time:12-17

Lets start off with the code

if($request->berbix == true || $request->berbix == 'true'){
          THIS IS WHERE I NEED THE LOGIC TO GO  
        }
        else {
        session()->flash('flash.banner', 'Profile updated!');
        session()->flash('flash.bannerStyle', 'success');
        return Redirect::route('dashboard');
        }

In the if statement this is what needs to happen.

  • user needs to be send to /verification/create with their user model
  • When that is completed, it will provide a URL
  • user then needs to be redirected to said URL

I know this should be simple but I am having a HECK of a time wrapping my head around the simple logic. The main thing I am struggling with (and I know why, but don't know how to solve it), is when I do for example Http::get() it isnt sending it as the user so the request doesn't know the user info

Any help either a solution or a nudge on what I need to do would be very nice right now!

CodePudding user response:

While I would still consider redirecting to a different route/controller to handle this, since you said you want it all in one place, it is possible to call controller methods directly and retrieve a response without leaving the current method or creating another HTTP request.

You could do something like this.

$url = app()->call('App\Http\Controllers\VerificationController@create', [
    'user' => auth()->user()
]);

if ($url) {
    return redirect($url);
}
  • Related