Extract value as comma separated list

Viewed 4969

I have a list below and i want to get a list of value as comma-separated values:

[{"id":49},{"id":61},{"id":5},{"id":58}] 

I tried pluck but it only returns single value. I want:

49,61,5,58

I can do it in many ways but i want to do it in laravel way.

Code:

   $locations = Location::select('id')->whereIn('id', function($query) use ($id)
            {
                $query->select('location_id')
                    ->from('users_locations')
                    ->whereRaw('user_id ='.$id);
            })->get();
5 Answers
Related