NBA ALL
NBA ALL

Reputation: 11

function Redirect in laravel

I don't know how to use this function in laravel 5.2.

function Redirect($url, $permanent = false){
    if (headers_sent() === false){
        header('Location: ' . $url, true, ($permanent === true) ? 301 : 302);
    }
    exit();
}

Can anyone tell me how to use it.

Thanks

Upvotes: 0

Views: 95

Answers (1)

Lijesh Shakya
Lijesh Shakya

Reputation: 2540

Lets suppose you need to redirect to the url /cats from the controller. You can simply use redirect() global function as

Route::get('/redirect', 'CatController@returnRedirect');

//CatController

public function returnRedirect(){

       return redirect('/cats');

}

For more information, you can visit the Laravel 5.2 Response

Upvotes: 1

Related Questions