在 laravel 分页中添加一些数据
2022-08-30 21:33:39
正如小花公所说,这是我的控制器
$book = Data::where('userId','1')->paginate(3);
return response()->json($book);
并获取如下所示的 json 数据:
data:[{id: 1, userId: 1, vendorId: 1, name: "Alfreda Berge PhD", phone: "1-850-813-5950 x96169",…},…]
from:1
last_page:2
next_page_url: "http:/localhost/XX/public/user/book/list/1?page=2"
perpage:4
prev_page_url:null
to:4
total:5
// if I want to add a new column and value here ,what should I do?
我试图这样做:
$book = Data::where('userId','1')->paginate(3);
$book->printWord = 'Hellow!';
return response()->json($book);
但是,它似乎会删除列 。有什么想法吗?printWord