Laravel Redirect from Helper Class

  laravel, laravel-controller, oop, php

I’m trying to redirect to an external URL from a helper class.

Here’s my controller:


namespace AppHttpControllers;

use AppLead;
use IlluminateHttpRequest;
use App;
use Helper;

class MyController extends Controller
    public function entities_get() {
        Helper::my_function(); // <---- Call my Helper class method to redirect.

        return view( 'template' );


Here’s my helper class used in the controller:


namespace AppHelpers;

class Helper
    public static function my_function()
        return redirect()->away( '' ); // <---- Not redirecting.

Why is the redirect() not working inside my_function()? Do I need to include some Laravel classes using the PHP "use" statement?

Source: Laravel

Leave a Reply