Menu

## BaseResponse
in package

BaseResponse.php : 28

This provides a uniform response format for our entire application.

All requests that hit the application will be handled successfully, so a http status code of 200 OK is expected for all requests whether they resolved with an error or not.

This gives us an opportunity to define our own status code based on the business requirements.

This also helps the server recover gracefully after every panic since all exceptions will be caught and handled

##### Tags

author

  Jet - ezrajet9@gmail.com

### Table of Contents

#### Properties

$data : Arrayable|null
$extraData : mixed
$returnCode : mixed
$returnData : mixed
$returnMessage : mixed
$extraData : mixed
$prettyResponse : string|null
$response : array<string|int, mixed>|null
$returnCode : int
$returnData : mixed
$returnMessage : string|null

#### Methods

__construct() : mixed
build() : BaseResponse
  This is used to build the response.
getPrettyResponse() : string|null
jsonResponse() : BaseResponse
  All actions in Pionia must return this as the response. This is how Pionia ensures a uniform response format

### Properties

#### $data

BaseResponse.php : 38
`public Arrayable|null $data = null`

#### $extraData

BaseResponse.php : 0
`public mixed $extraData`

- any other data you want to send to the front-end, any!!

#### $returnCode

BaseResponse.php : 0
`public mixed $returnCode`

defaults to 0 for success. Any other code other than 0 implies an error. This can customized to your needs

#### $returnData

BaseResponse.php : 0
`public mixed $returnData`

- the data the server wants to send to the frontend, can be of any data format

#### $returnMessage

BaseResponse.php : 0
`public mixed $returnMessage`

- the message the server wants to send to the frontend

#### $extraData

BaseResponse.php : 33
`private mixed $extraData = null`

#### $prettyResponse

BaseResponse.php : 34
`private string|null $prettyResponse = null`

#### $response

BaseResponse.php : 36
`private array<string|int, mixed>|null $response = null`

#### $returnCode

BaseResponse.php : 30
`private int $returnCode = 0`

#### $returnData

BaseResponse.php : 32
`private mixed $returnData`

#### $returnMessage

BaseResponse.php : 31
`private string|null $returnMessage = null`

### Methods

#### __construct()

BaseResponse.php : 40
`public __construct([mixed $data = null ]) : mixed`

##### Parameters

$data : mixed = null

#### build()

BaseResponse.php : 80

This is used to build the response.

`public build([array<string|int, mixed>|null $additionalData = [] ]) : BaseResponse`

##### Parameters

$additionalData : array<string|int, mixed>|null = []

##### Return values

BaseResponse

#### getPrettyResponse()

BaseResponse.php : 48
`public getPrettyResponse() : string|null`

##### Return values

string|null

#### jsonResponse()

BaseResponse.php : 62

All actions in Pionia must return this as the response. This is how Pionia ensures a uniform response format

`public static jsonResponse([int|null $code = 0 ][, string|null $message = null ][, mixed|null $data = null ][, array<string|int, mixed>|string|null $extraData = null ]) : BaseResponse`

##### Parameters

$code : int|null = 0
  - the return code to the client side. Defaults to 0 for success
$message : string|null = null
  - the message to send to the client side
$data : mixed|null = null
  - the data to send to the client side
$extraData : array<string|int, mixed>|string|null = null
  - any other data to send to the client side

##### Return values

BaseResponse

## Search results