Thursday, April 13, 2017

Manipulating returned eloquent collections

I was under the assumption that Eloquent returns collections, so the below would work;

$all_locations = Service::getLocationsForService($service_id, 'all');

$chosen_locations = Service::getLocationsForService($service_id, $locations);

$diff = $chosen_locations->diff($all_locations)

However I just get Call to undefined method Illuminate\Database\Query\Builder::diff()

Are these https://laravel.com/docs/5.4/collections#available-methods only available at the point of making the query, and not manipulating an already returned collection?



via Craig Ward

Advertisement