How would you adapt Backpack to access an external API? #434
-
I'd like to use the front end of Backpack (table display, sort, filter,buttons, etc) to request, show and send data from/to an external json API, instead of a local mysql database. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @gitbuddy99! From what I understood, you wanted to replace SQL, with some external JSON API, is that it? Let me explain, Backpack uses Laravel Eloquent Models and you are able to use any database driver you want, you may replace If you use So, if you find or develop a database driver that stores and retrieves data from a JSON API, it should fit your needs. I'm not aware of any by the way, but let us know if you achieve it 👌 |
Beta Was this translation helpful? Give feedback.
-
You should be able to do that using Sushi, yes - https://github.com/calebporzio/sushi . It allows you to create "Eloquent Models" out of arrays. And if you populate those arrays from your API - boom, you have what you asked for, Eloquent models that work with your API instead of your DB 😉 Then just use those Models in Backpack normally. We do that in our DevTools addon and it works very well. Not all Eloquent features are supported (obviously!) but most of the common ones are. Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
/gpt could you please reply to the question in this thread, detailing how to use the Laravel Sushi package, in order to have the Eloquent Model use an external API to get the data... then create a Backpack CRUD for that Eloquent Model? |
Beta Was this translation helpful? Give feedback.
You should be able to do that using Sushi, yes - https://github.com/calebporzio/sushi . It allows you to create "Eloquent Models" out of arrays. And if you populate those arrays from your API - boom, you have what you asked for, Eloquent models that work with your API instead of your DB 😉 Then just use those Models in Backpack normally.
We do that in our DevTools addon and it works very well. Not all Eloquent features are supported (obviously!) but most of the common ones are.
Hope it helps!