codecasts / spa-starter-kit

A highly opinionated starter kit for building Single Page Applications with Laravel and Vue.js
MIT License
913 stars 134 forks source link

Transformers #41

Closed flyingluscas closed 7 years ago

flyingluscas commented 7 years ago

Transformers feature added, freeing the controller from making the decision of what data structure send back to the client.

A request to /api/categories/1 will now return something like this

{
    "data": {
        "id": 1,
        "name": "omnis",
        "created_at": "2016-12-05 12:07:08",
        "updated_at": "2016-12-05 12:07:08"
    }
}

and a request to /api/categories will return something like this

{
    "data": [
        {
            "id": 1,
            "name": "omnis",
            "created_at": "2016-12-05 12:07:08",
            "updated_at": "2016-12-05 12:07:08"
        },
        {
            "id": 2,
            "name": "omnis",
            "created_at": "2016-12-05 12:07:08",
            "updated_at": "2016-12-05 12:07:08"
        },
    ],
    "meta": {
        "pagination": {
            "total": 200,
            "count": 10,
            "per_page": 10,
            "current_page": 1,
            "total_pages": 20,
            "links": {
                "next": "http://localhost:8000/api/categories?page=2"
            }
        }
    }
}

This is a big change, this will impact on how the client uses the API to retrieve categories, so @vedovelli the client will need to be updated as well.

vedovelli commented 7 years ago

@flyingluscas Thanks! I'll deal with that tomorrow!

flyingluscas commented 7 years ago

@vedovelli ok sir :)

vedovelli commented 7 years ago

I'm waiting for @flyingluscas and @vinicius73 to send their PRs to fix the application. Thanks.

flyingluscas commented 7 years ago

I'm waiting for @cristianopacheco fix the auth problems, then I will solve the conflicts on this PR, meanwhile I'm gonna see if there is anything else breaking.