【发布时间】:2017-03-17 04:37:15
【问题描述】:
我正在尝试从 laravel eloquent 查询中获取结果集,借此我将列与数组中的值列表进行匹配。
$authenticated_operation_ids = AccessControl::where('user_id', '=', $user_id)
->where('entity_type_id', '=', $operation_entity_id)
->pluck('entity_access_id')->toArray();
$authenticated_operations = Operation::whereIn('id', $authenticated_operation_ids);
return view('page.index')->withOperations($authenticated_operations);
【问题讨论】:
-
您在查询结束时忘记了
->get()。 -
在 mongodb 中,本地 id 被创建为 _id 属性。如果你不是故意的,你应该把 id 改成 _id。
标签: php arrays laravel where-in