Closed vinkla closed 9 years ago
Not really possible because the serializers must adhere to an interface, so they can't stray from that with type hints.
Instead, you can do something like this:
public function getAttributes($user) {
if (!($user instanceof User)) {
throw new InvalidArgumentException;
}
}
Okay, to bad.
@tobscure do you have any examples or tips for integrating the new version with Laravel?
See these methods for an example implementation
Thanks! How would go about binding the document to Laravel request?
The Document object implements the JsonSerializable interface so you should be able to pass it right into the response
helper, e.g.:
return response($document)
->header('Content-Type', 'application/vnd.api+json');
Awesome, thanks for helping out!
Wouldn't it be nice if we could typehint what model we're throwing to the serializers?
Would this be possible to implement and would it take long time to do?