all() as $item) { $items[] = $item->toResource($excludes); } $collection = new Collection($items); if ($this instanceof Collection) { return $collection; } return $this->setCollection($collection); } /** * Filter the resource to exclude properties * * @param array $resource * @param array $excludes * @return array */ public function filterResource($resource, $excludes) { if ($excludes) { foreach ($resource as $key => $value) { if (in_array($key, $excludes)) { unset($resource[$key]); } } } return $resource; } }