RESTful API - 收集Laravel 5的数组
I'm having issues with an array returned from
DB::select(). I'm heavily using
Collections of eloquent models in my API. Unfortunately, DB::select returns an array, which obviously doesn't work with skip and take's. How would one convert arrays to a collection that can utilise these methods?
Which doesn't quite work as I expected, as it wraps the entire array in a Collection, not the individual results.
Is it possible to convert the return from a
DB::select to a 'proper' Collection that can use
I've also tried:
$query = \Illuminate\Support\Collection::make(DB::table('survey_responses')->join('people', 'people.id', '=', 'survey_responses.recipient_id')->select('survey_responses.id', 'survey_responses.response', 'survey_responses.score', 'people.name', 'people.email')->get());
Which still tells me:
FatalErrorException in QueryHelper.php line 36: Call to a member function skip() on array