radiate-framework / framework

A WordPress plugin and theme framework
https://radiate-framework.github.io/
MIT License
4 stars 0 forks source link

JsonResource toArray doesn't have Request passed through #45

Closed BenRutlandWeb closed 3 years ago

BenRutlandWeb commented 3 years ago

Describe the bug When running make:resource command, the stub generated has the Request object passed as the only method parameter. In reality, the JsonResource doesn't actually get the request passed, so the method signature doesn't match the parent class.

To Reproduce Steps to reproduce the behavior:

  1. run wp radiate make:resource TestResource
  2. inspect the newly created resource
  3. attempt to dump the $request parameter

Expected behavior The dumped $request parameter to output a Radiate\Http\Request instance

Additional context The JsonResource::toArray method doesn't get passed the Request. It should in order to replicate the same functionality of Laravel, or the stub shouldn't include the parameter if the resource is deemed to not require it.

IMO the resource should get an instance of the request, or even have all dependencies resolved from the container. This would give great flexibility when building the resource.