Welcome Guest, Not a member yet? Register   Sign In
Redirect inside Constructor NOT WORKING
#1

Hello All,

I need help with a explanation on WHY a "return redirect->to()" wont work inside a constructor...

This wont work:

PHP Code:
    public function __construct()
    {
        return 
redirect()->to('http://www.google.com');
    }


    public function 
index()
    {
        echo 
'Hello World!!!!!';
    } 
 
This will work:

PHP Code:
    public function __construct()
    {
        
    }


    public function 
index()
    {
        return 
redirect()->to('http://www.google.com');
        
        echo 
'Hello World!!!!!';
    } 

Of course this is only a example and I will have some logic inside the constructor, like: if(NotLogged){ redirect() }

Thank you for the explanation...
Reply


Messages In This Thread
Redirect inside Constructor NOT WORKING - by Poetawd - 10-06-2019, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB