We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

How to redirect in Addon

Jonas Siewertsen October 10, 2019 by Jonas Siewertsen

I am trying a really simple thing, but i seems like i cant figure it out. There are two things i want to do:

  1. Check if the url exists
  2. Redirect if it does

Inside my addon controller, i got something like this:

class AddonListener extends Listener
     * The events to be listened for, and the methods to call.
     * @var array
    public $events = [
        'response.created' => 'response',

    public function response(Response $response)
            if (Cookie::has('somesavedurl')) { //pagetogoto

                $path = base_path() . Cookie::get('somesavedurl'); 

                // how to check if the path/route exists ?

                return redirect($path); // Not doing anything

It feels stupid, that its not working ... :-)

Answered by Jonas Siewertsen!
>>>>>>> Answered <<<<<<<
2 Replies
1 Follower