我有一个中间件,它使用重定向来调用一个控制器,然后显示一个视图。
public function handle($request, Closure $next)
{
redirect()->action('Full'Namespace'To'Controller'ErrorController@fourOhThree');
}
我也有这条路线。当我沿着路线行驶时,视图显示得很好。当我尝试使用action
重定向并传递控制器的命名空间时,laravel会尝试在基本应用程序中找到控制器。我得到错误
Action App'Http'Controllers'Full'Namespace'To'Controller'ErrorController@fourOhThree not defined.
当控制器位于时
App'Vendor'Myname'Mypackagename'Controllers'ErrorController@fourOhThree
我已经尽我所能正确地命名了我的控制器,因为它与这个目录中的其他命名控制器相匹配。这是我试图通过操作调用的唯一控制器。
App'Vendor'Myname'Mypackagename'Controllers
中的ErrorController.php
namespace Full'Namespace'To'Controller;
use App'Http'Controllers'Controller;
class ErrorController extends Controller
{
public function fourOhThree()
{
return view('...');
}
}
我认为我在将名称空间控制器传递给action
方法的过程中做错了什么。
尝试在限定名称前面添加一个''''。
action(''Full'Namespace'To'Controller'ErrorController@fourOhThree')