TP6框架 BaseController内 redirect()函数无法跳转


这个需要自定义一个 rediectTo方法,放到 BaseController 里面
/**
     * 自定义重定向方法
     * @param $args
     */
    public function redirectTo(...$args)
    {
        // 此处 throw new HttpResponseException 这个异常一定要写
        throw new HttpResponseException(redirect(...$args));
    }

 

然后在 BaseController初始化方法里面就可以调用了

 //登录验证
$check_res = $this->adminLoginCheck();
if ($check_res['status']=='SUCCESS') {
         $this->admin_info = $check_res['data'];
         $this->admin_id = $this->admin_info['admin_id'];
}else{
        return $this->redirectTo('/admin/login/index');
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM