Request and Resource binding #8
reindert-vetter
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi! Great module. I Just tried the example out with binding a JsonResource (using Laravel 8) and got an error - P.S. I tried to see what would make it work as described in the specs. I came up with something like this in the Bind's handle method: use Illuminate\Http\Resources\Json\JsonResource;
//....
public function handle(Request $request, Closure $next)
{
if (is_subclass_of($this->concrete, JsonResource::class)){
app()->bind($this->abstract, function(Container $container){
return new $this->concrete(new \stdClass);
});
} else {
app()->bind($this->abstract, $this->concrete);
}
return $next($request);
} P.P.S. I created a merge request with that: #17 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is the documentation not completely clear? Then ask your question here.
Beta Was this translation helpful? Give feedback.
All reactions