Skip to content

Instantly share code, notes, and snippets.

@sidigi
Last active September 15, 2021 10:34
Show Gist options
  • Save sidigi/f3b9ec805dcf4926ddea18b74e81c7b2 to your computer and use it in GitHub Desktop.
Save sidigi/f3b9ec805dcf4926ddea18b74e81c7b2 to your computer and use it in GitHub Desktop.
Test Api Resource
<?php
TestResponse::macro('fromResource', function(JsonResource $resource, ?Request $request = null){
$request = $request ?? request();
return new static($resource->toResponse($request));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment