laravel常用功能总结

1.捕获没有连接的空路由

    在app/exception/handle.php class Handler 下下面的render方法

     public function render($request, Exception $e)
     {
         return parent::render($request, $e);
     }

修改为

    public function render($request, Exception $e)
    {
        if ($this->isHttpException($e))
        {
            dd("errer page");//这里可以捕获空路由
            return $this->renderHttpException($e);
        }
        else
        {
           // dd("errer page");
            return parent::render($request, $e);
        }
    } 

2.返回JSON

在controller中处理方法中return response()->json($this->res);

posted @ 2017-03-06 21:42  米斯特尔曾  阅读(115)  评论(0)    收藏  举报