Response methods

Controllers with traits Api or Web have the following response methods available. These have been handled but can be overriden to further customize the response.

success

parameters

  • $response (mixed) - The response to send to the client.
  • $code (integer) - The response code. Default is 200.

paginatedList

Relies on the success method.

parameters

  • $items (array) - The items in the pagination
  • $code (integer) - The response code. Default is 200.
  • $meta (array) - The data to add to the meta array in the response

error

parameters

  • $message (string) - The error message
  • $errors (mixed) - The errors to send with the message
  • $code (integer) - The response code. Default is 400.

validationError

Relies on the error method. Called when there's a validation error.

parameters

  • $errors (mixed) - The errors to send

storeFailedError

Relies on the error method. Called when the storing a model fails.

updateFailedError

Relies on the error method. Called when the updating a model fails.

destroyFailedError

Relies on the error method. Called when the destroying a model fails.

restoreFailedError

Relies on the error method. Called when the restoring a soft-deleted model fails.

notFoundError

Relies on the error method. Called when the a targeted model is not found.

modelNotSetError

Relies on the error method. Called when method model() returns falsable.