mardi 5 janvier 2016

Redirect action to controller in different namespace

I have middleware that uses a redirect to call a controller which then displays a view.

public function handle($request, Closure $next)
{
    redirect()->action('Full\Namespace\To\Controller\ErrorController@fourOhThree'); 
}

I also have this as a route. When I follow the route the view is displayed fine. When I try and redirect using action and pass the namespace of my controller, laravel tries to find the controller in the base app. I get error

Action App\Http\Controllers\Full\Namespace\To\Controller\ErrorController@fourOhThree not defined.

When the controller is located at

App\Vendor\Myname\Mypackagename\Controllers\ErrorController@fourOhThree

I have namespaced my controller correctly as far as I can tell as it matches the other namespaced controllers in this directory. This is the only controller I am trying to call from an action.

ErrorController.php within App\Vendor\Myname\Mypackagename\Controllers

namespace Full\Namespace\To\Controller;

use App\Http\Controllers\Controller;

class ErrorController extends Controller
{
    public function fourOhThree()
    {
        return view('...');
    }
}

I think I am doing something wrong in how I am passing the namespaced controller to the action method.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Sx3Zjz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire