-
Notifications
You must be signed in to change notification settings - Fork 0
Resource casting
plokko edited this page Feb 22, 2021
·
3 revisions
Data rapresentation can be customized by integrating auto casting to Eloqent API Resource.
After defining your JsonResource class you can specify it either by setting the protected $useResource
field
class TestQuerableResource extends \Plokko\QuerableResource\QuerableResource {
protected $useResource = YourJsonResourceClass::class;
protected function getQuery(): Illuminate\Database\Eloquent\Builder
{
return App\User::where('id','>',0); // Just a simple query to demonstrate functionality
}
}
or by calling useResource
method
$qr->useResource(YourJsonResourceClass::class);