-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make a request to one endpoint from another controller #634
Comments
Hi! I wouldn't ever recommend creating a new request within an existing Laravel request, as Laravel assumes it is only handling one request at once. Why don't you just update the user model yourself? Why do you have to pass it off as a JSON:API process? |
@lindyhopchris I want to reuse the api endpoints. And i want also to benefit of the already implemented validations and rules in place in this api endpoint. I already used this logic for the passport api without trouble like this:
|
Sending a request within another request is just not something I'd recommend doing. Using the HTTP client would seem like a lot better idea. I think this shows a need for a developer being able to execute a JSON:API "operation" wherever they want. This is something I'd support in a future version, as I need to separate out the operations to support the Atomic Operations extension. However, at the moment that's not something that's supportable in the current codebase as the operations are coupled to the HTTP requests due to using form request classes. |
Okay thanks, i will go with the http client then. |
I'm going to leave this open as a reminder that I need to make it easier for developers to manually trigger a JSON:API operation. |
Hello,
How do i make a request to one resource endpoint without using an http client?
Here is my problem I have create a controller to update the current user informations. I have a users ressource configured. When i try to create a request like this and pass it to the app()->handle() functions the request fails with a 500 error :
$request = Request::create(
'/api/v1/users/1',
'POST',
$data,
);
$response = app()->handle($request);
is there a way to call a ressource controller action without using an $httpClient?
The text was updated successfully, but these errors were encountered: