这是我的查询
$data=Auth::user()->roles()->with('permissions')->get()->pluck('permissions');
return $data;
查询的输出如下:
[
[
{
id: 2,
name: "Read",
slug: "Read",
description: "This is Simple Read Permission",
pivot: {
role_id: 2,
permission_id: 2,
},
},
{
id: 3,
name: "Update",
slug: "Update",
description: "This is Simple Update Permission",
pivot: {
role_id: 2,
permission_id: 3,
},
},
]
]
现在,我想将其转换为数组。我已经使用过map()
和toArray()
函数,但是结果仍然保持相同的格式。
如何将该集合转换为数组?