当我使用laravel分页时,我得到一个这样的对象:
{
"per_page": 1000,
"current_page": 2,
"next_page_url": null,
"prev_page_url": null,
"from": null,
"to": null,
"data": []
}
我想在该对象中添加'过滤器'我的控制器中的属性,以便在响应中返回已添加的过滤器。像这样:
{
"per_page": 1000,
"current_page": 2,
"next_page_url": null,
"prev_page_url": null,
"from": null,
"to": null,
"data": [],
"filters" : []
}
当我尝试在我的控制器中执行此操作时,例如
$paginated->filters = [ ];
它没有效果,响应对象保持不变。
有什么想法吗?
提前致谢
答案 0 :(得分:0)
您可以使用namespace restaurant{
attribute userId{
category = subjectCat
id = "restaurant.userId"
type = string
}
attribute owner{
category = resourceCat
id = "restaurant.resourceCat"
type = string
}
policy restaurant{
target clause objectType == "restaurant"
apply firstApplicable
rule ownerCanView{
target clause actionId == "view"
permit
condition userId == restaurant.owner
}
}
}
获取响应数组。然后你可以随心所欲地修改它。
present(viewControllerToPresent: yourVC , animated: true, completion:nil)