Skip to content
Advertisement

Return custom array in json model with Lumen

With Lumen 8 I have :

  • Model : Store
  • Controller : StoreController
  • Repository : StoreRepository

I can get my Store without any problem and get the json below :

JavaScript

I would like to get open/close time of the Store. In my model I have a array (for test) and I can show it like that :

JavaScript

And get this result :

JavaScript

The problem is that I have 2 sections now. How I can have this array inside my store value ? like below :

JavaScript

Advertisement

Answer

Missreaded, in Laravel, you can use Resources API Resources, I guess in Lumen no, more docs here: https://laravel.com/docs/8.x/eloquent-resources

And in your resource, just have something like:

JavaScript

Or just return something like this:

JavaScript

Why 404 btw?

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement