Laravel Pluck未能在模型上工作

时间:2018-01-03 07:21:47

标签: php laravel-5

我试图在特定数据上搜索id但是失败

$id=PermissionsAssignment::pluck('permission')->
       where('category', $request->filter_category)->all();

当我检查var_dump($request->filter_category)时,它有例如:1

当我表演时

 $data= PermissionsAssignment::where('category','=', $request->filter_category)->get();

它产生

[
   {name:'', permission:1, category:1}
   {name:'two', permission:2, category:1}

         ....etc
]

为什么拔除不起作用,因为我希望它返回权限值。

1 个答案:

答案 0 :(得分:1)

删除all()来电并仅使用pluck()

$id=PermissionsAssignment::where('category', $request->filter_category)
                         ->pluck('permission');