Skip to content

Commit

Permalink
use tap
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopedra committed Mar 26, 2019
1 parent 3e146d5 commit 502492e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Illuminate/Http/Resources/Json/JsonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public static function make(...$parameters)
*/
public static function collection($resource)
{
$collection = new AnonymousResourceCollection($resource, static::class);

$collection->preserveKeys = property_exists(static::class, 'preserveKeys') && (new static([]))->preserveKeys === true;

return $collection;
return tap(new AnonymousResourceCollection($resource, static::class), function ($collection) {
if (property_exists(static::class, 'preserveKeys')) {
$collection->preserveKeys = (new static([]))->preserveKeys === true;
}
});
}

/**
Expand Down

0 comments on commit 502492e

Please sign in to comment.