douqie3391
2019-07-17 07:37
浏览 314
已采纳

如何从laravel中的Array中提取值?

Let just say i have this [{"id":21},{"id":22}] array coming up from this :

$schedules = [];
    foreach ($routes as $route) {
        $schedules[] =Schedule::select('id')
                        ->whereIn('route_id', $route)
                        ->latest()
                        ->first();  
    }

So, i want to extract the value from it like this [21,22], so i did it like this:

$values = $schedules->pluck('id')->toArray();

this showing this error

Call to a member function pluck() on array

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题