I have a need to build some custom backend plugins where all data is fetched from and saved to a remote REST API. There are a few projects floating around that provide an Eloquent-like model class that does just that (https://github.com/Torann/remote-model). The goal would be able to take advantage of all the wonderful OctoberCMS features that make it easy to whip together backend CRUD functionality, while under the hood the octobercms database would never be touched.
When trying to build a proof-of-concept, I quickly realized this was going to be harder than I first thought since many of the backend widgets seem to build up queries manually instead of relying on eloquent methods.
I guess my question is, has anybody else tried anything like this before? I don't know enough about the octobercms internals to know just how long of a road tackling something like this might be...
Andrew, did you make any progress with this? I also had the same idea. I wanted to extend User plugin to use remote-api as data source.
just adding a me too here, trying to figure out the octobercms plugins for the exact same purpose.... and could only find your post..... think the problem is asking the wrong question...
took me some time to figure this out and so far i think following this route would be the right way to follow. https://octobercms.com/forum/post/how-to-create-a-custom-html-page-in-backend
this simply leads to the plugin menu in october cms on the top and side pannel and an empty page... in this empty page you can create your php html api magic since it does not touch the octobercms database.
next problem would be re-integrating your standalone api pages a bit with some of the octobercms framework so you keep the same look and feel as the other plugins, but still working on this.
A quick and dirty solution would be to create model the october way, create the database table (without any columns) because it's required, but marking all fields as $purgeable using the purgeable trait
Like that you can create your model fields and columns the standard way (even with the builder plugin to manage your fields.yaml and columns.yaml) but when you have to fetch the data, you use your custom code that retrieve the infos from the API of your choice.
I needed to do that on a product model to manage the stock level from an API instead of locally. I created a purgeable "stock" field, used the beforeSave() method to update the stock on the API side (using PUT) and I used the afterFetch() method to get the stock from the API when I need to display it (using GET)
Don't know if it's the right method and if performances would be ok for lot of fields / complete API sync, but for my stock field, it works pretty well.
I don't know if october is smart enought to make this method works with backend filters without any extra code, I need to test that
1-4 of 4