API
All the deep details of this library goes here.
Illuminate\Database\Eloquent\Builder
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\Builder
jsonApiPaginate
Transforms collection of query results of valid JsonApiable
resources to a paginated JSON:API collection (JsonApiCollection
).
Parameters:
pageSize
null
columns
['*']
page
null
Example:
Illuminate\Support\Collection
Extending the framework Illuminate\Support\Collection
.
Source: OpenSoutheners\LaravelApiable\Collection
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