Laravel-json-api: Exclude self link from resource

Created on 25 Sep 2017  路  2Comments  路  Source: cloudcreativity/laravel-json-api

Simple one (I hope).

How do I hide the links section if it isn't required? For example:

GET https://app.dev/api/locums/F00BBDCF-62D5-4C2D-ADFB-B62615D64271/currency

{
    "data": {
        "type": "currencies",
        "id": "GBP",
        "attributes": {
            "name": "British Pound Sterling"
        },
        "links": {
            "self": "https://loc8um.dev/api/currencies/GBP"
        }
    }
}

The 'self' link there is not (and will not be) available, so I'd like to not include the 'links' section in that response.

Cheers,

Dan

question

Most helpful comment

Add this to your currencies schema:

    public function getResourceLinks($resource)
    {
        return [];
    }

All 2 comments

Add this to your currencies schema:

    public function getResourceLinks($resource)
    {
        return [];
    }

Perfect - thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

umbert-cobiro picture umbert-cobiro  路  4Comments

petenys picture petenys  路  5Comments

pro-cms picture pro-cms  路  5Comments

jelhan picture jelhan  路  6Comments

lindyhopchris picture lindyhopchris  路  6Comments