mercredi 23 mai 2018

Redirect in the helper file does not work in Laravel

The redirect() helper function in the helper file does not work in Laravel. Here is my code helpers.php

if (! function_exists('license_check')) {
    function license_check(){
        //This does not work, returns a blank page
        return redirect()->route('loginlicense');
        //This does not work, returns a blank page
        return \Redirect::route('loginlicense');
        //This work but it prints on the browser before redirecting
        echo \Redirect::route('loginlicense');
        echo redirect()->route('loginlicense');

        //This work but it prints on the browser before redirecting
        die(\Redirect::route('loginlicense'));
        die(redirect()->route('loginlicense'));

        //The below works. But I would like to pass laravel flash sessions with `Laravel's with('status', 'My mesage')`

        $url = route('loginlicense');
        header("Location: ".$url);
        exit();
    }
}

license_check();

Why am I getting a blank page instead of being redirected to the url specified while using Redirect:: or redirect().



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2s4BPog
via IFTTT

Aucun commentaire:

Enregistrer un commentaire