API

All the deep details of this library goes here.

Illuminate\Database\Eloquent\Builder

circle-info

Please, note the difference between Collection and Builder coming from an Eloquent model, because that conditions the accesibility of these and other methods.

Extending the framework Illuminate\Database\Eloquent\Builder.

Source: OpenSoutheners\LaravelApiable\Builderarrow-up-right

jsonApiPaginate

Transforms collection of query results of valid JsonApiable resources to a paginated JSON:API collection (JsonApiCollection).

Parameters:

Name
Default

pageSize

null

columns

['*']

page

null

Example:

App\Models\Post::where('title', 'my filter')->jsonApiPaginate();

Illuminate\Support\Collection

Extending the framework Illuminate\Support\Collection.

Source: OpenSoutheners\LaravelApiable\Collectionarrow-up-right

toJsonApi

Transforms collection of valid JsonApiable resources to a JSON:API collection (JsonApiCollection).

Note: This method doesn't paginate, for pagination take a look to the Builder::jsonApiPaginate.

Parameters:

None...

Example:

OpenSoutheners\LaravelApiable\Contracts\JsonApiable

Model contract.

toJsonApi

If the model below implements OpenSoutheners\LaravelApiable\Contracts\JsonApiable and uses the trait OpenSoutheners\LaravelApiable\Concerns\HasJsonApi, you could do the following to transform the model to JSON:API valid response:

OpenSoutheners\LaravelApiable\Support\Apiable

These methods are available as global helpers functions (see examples).

config

Method used to get user config parameters for this specific package.

Example:

toJsonApi

Transform passed value (can be instance of different types: Builder, Model, Collection, etc...).

Example:

resourceTypeForModel

Guess resource type from model class or instance.

Example:

getResourceType

Get resource type from model class or instance (if one specified, otherwise guess it using resourceTypeForModel method).

Example:

jsonApiRenderable

Render errors in a JSON:API way. Check documentation on how to integrate this in your project.

Example:

response

Render content as a JSON:API serialised response. Check documentation on how to customise these reponses.

Example:

Last updated