我要实现的目标:要访问并打印集合的元部分
我尝试过的事情:
$products = products::where('product_name', 'LIKE', '%' . $q . '%')
->where('product_status', 1)
->where('publish_status', 1)
->orderBy('id', 'DESC')
->paginate(8);
// dd($products);
$products->appends(array(
'query' => Input::get('search_text')
));
return Searchmanager::collection($products)->additional([
'meta' => [
'min_mrp' => '100',
]
]);
这是我的资源部分:
public function toArray($request)
{
return parent::toArray($request);
//dd($this->meta) what i tried but not working
}
这是我的回复:
{
"data": [
{
"id": 37,
"product_webid": "pmtrj0vwj4",
"product_name": "Samsung Galaxy Note 9",
"slug": "samsung-galaxy-note-9",
"description": "demo",
}
],
"links": {
"first": "https://mobileappdatabase.in/ecomv2/api/search?query=sam&page=1",
"last": "https://mobileappdatabase.in/ecomv2/api/search?query=sam&page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "https://mobileappdatabase.in/ecomv2/api/search",
"per_page": 8,
"to": 7,
"total": 7,
"min_mrp": "100"
}
}
我尝试了dd($ request); ,$ this-> meta,$ this-> meta ['mn_mrp'],$ this-> collection-> meta对我不起作用,请帮帮我。