alaravel中的分页键

时间:2018-08-28 14:17:38

标签: laravel api pagination

我想使用分页返回常见的api服务 分页,但它不会返回如下键:

"first_page_url": "http://localhost/project/api/ar/faqs?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http://localhost/project/api/ar/faqs?page=1",


 if (config('app.locale') === 'en') {
        $data = Faq::paginate(10)
                    >transform(function($faq, $key) {
                            return [
                                'id' => $faq->id,
                                'question' => $faq->translate('en')->question,
                                'answer' => $faq->translate('en')->answer,
                            ];        
                        });

   return $this->respondWithSuccess($data);
 } else {
            $data = Faq::select('id', 'question', 'answer')->paginate(10);

  return $this->respondWithSuccess($data);

}

在本地应用分页时,如何返回像thit这样的键

0 个答案:

没有答案