Connecting to external API and redirecting after success
Not fully understanding how much of the business logic should be in the Resource classes, or if those are more strictly used for forms and tables?
Related to the above, I have a "Location" model and an action button on my edit location page (defined in EditLocation resource class) that redirects to an external URL that connects to an API integration.
Once the API connection is successful, it redirects back to my application and passes along some data to validate. In the old (non-filament) version of my app, I would then just return redirect to the locations.edit view and they're back where they started, and there's a toastr message that pops up indicating the action was successful.
Here's what I have in my EditLocation Resource class:
3 Replies
Am I putting this logic in the right place? It works up until the point where I need to redirect. I don't know how to accomplish that. I tried adding this to my web routes:
Route::get('locations/{location}/edit', EditLocation::class)->name('locations.edit');
I at least figured out part of the problem by running sail artisan route:list
and finding out that the name of the route was different than what I was using, so I got it working. Still not sure if the connect()
method I showed should be in the resource class or what's actually supposed to live there. I don't guess it matters, but just trying to understand best practices.As far as where to put your
connect()
function, it's fine if it's in that file since that's what it's related to. Or you could put it anyplace else that you have services/actions/etc that you want to centralize.ok, thanks for your help!