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);

浙公网安备 33010602011771号