我需要在api响应中设置标头。
我尝试过这样
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return Blog::all()->header('X-Total-Count', Blog::all()->count());
}
如何正确发送此邮件?
答案 0 :(得分:2)
基于documentation,以下操作应该有效:
return response(Blog::all())
->header('X-Total-Count', Blog::all()->count());