如何在Laravel Eloquent

时间:2019-01-07 18:41:07

标签: laravel eloquent

这是我的查询

$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()函数,但是结果仍然保持相同的格式。

如何将该集合转换为数组?

0 个答案:

没有答案