Support the ongoing development of Laravel.io →
Eloquent Architecture

I have a Post model, that read from my table "posts".

In my PostController, I inject an PostRepositoryInterface that is bound to an EloquentPostRepository by a service provider.

All works well, but I have a new problem:

For the creation and editing of the post, I don't want to show a form, I want to call an external API that will return some XML then I want to dispatch that information into my database.

I can do each step separately, but I'm not sure how to structure this whole scenario into something that is not a mess.

Where would I put the API-client code? Certainly this has nothing to do with my EloquentRepo, yet it still need to store the data into my database...

Last updated 3 years ago.
0

My personal solution right now : I have created a PostWebInterface with the implementation VendorPostWeb that I inject in my Post controller along with the classical repository and that I can use for the method like create and update.

I'm not sure it's the best way, but I don't think many developers use laravel as a SOAP client... So nobody can judge me :p

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

vanpet vanpet Joined 10 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.