Skip to content

Commit

Permalink
collect is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 23, 2017
1 parent 80a8ca9 commit f8db604
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Http/Resources/CollectsResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ trait CollectsResources
*/
protected function collectResource($resource)
{
$this->collection = $resource->mapInto($this->collects());
$this->collection = ($collects = $this->collects())
? $resource->mapInto($collects)
: $resource->toBase();

return $resource instanceof AbstractPaginator
? $resource->setCollection($this->collection)
Expand All @@ -38,8 +40,6 @@ protected function collects()
class_exists($class = Str::replaceLast('Collection', '', get_class($this)))) {
return $class;
}

throw new UnknownCollectionException($this);
}

/**
Expand Down
21 changes: 0 additions & 21 deletions src/Illuminate/Http/Resources/UnknownCollectionException.php

This file was deleted.

0 comments on commit f8db604

Please sign in to comment.