#report structure

1 messages · Page 1 of 1 (latest)

empty rover
#

hello, i have interesting topic

i need to prepare dynamic report, frontend will send me request with details about data i should return and i want to return object ready to paste to generic table
stack: lumen/vuejs

how it should works? (Simple example)

as user i want to see all workplaces with all data, and workplaces assigned to them, but only with id and name

whats the problem?

frontend should give me fields that he want to see, and i should return him obiect with record, im looking for good or the best approach to achieve it

report can contain nested data, example (for now) request from frontend:
example report: reports/users

{
    "columns": [
        "x",
        "y"
    ],
    "appends": [
        {
            "user": {
                "columns": [
                    "x",
                    "y"
                ]
            }
        }
    ]
}```

the current approach is prepare endpoint for few reports: users, workplaces....


in current build its easy to just make select and join relations, but i have a lot of pivots here, for example workplace can have devices - ok, im displaying devices, but because of its fully dynamic i cant use api resources (maybe im wrong), and problem appear when i have model_id in device, i want to display model: "string" (based on relation, model_id), the report can contain a lot of nested obiects, maybe i started plan of wrong side...what do you think? maybe i should return data with needed relations and frontend will display that it need base on headings?
#

important info: we dont have graphql in this project and we dont have time to implement it here

#

i want to make it without a lot of ifs, i want to make few reusable rules

#

i forgot to describe how report should work from user perspective, give me few mins

empty rover
#

😦

frank sparrow
#

Oh you want multiple filtering options

#

Use recursion. Or there is also some package I saw a while back

#

@empty rover

#

Recursion + WHERE is all it is

empty rover
#

Filtering works ok for me with eloquent, my biggest problem is i cant use api resources and display data from pivots, for example (on devices table): model: { id:…, name…} i want display model: name

#

By just query, but i can build object and adding properties to it, then i can

frank sparrow
#

You might need to change the resource so it also shows the relationship.

empty rover
#

Im using with and this returning new objects, but for a lot od them i want to return string, not object

#

In the model example

#

I overcomplicated few things (when i was working with it) so its hard to explain it good, sorry 😄 im little bit lost

#

what i got

{
    id: 1,
    "model": {
        "id": 1,
        "name": "thinkpad",
    }
}```

expected
```json
{
    id: 1,
    "model": "thinkpad"
}```
#

i always resolving thinks like that with api resources