JsonResponse
trait JsonResponse
A trait that support operations related to APIs and their associated JSON responses.
Methods
bool
apiCsrfCheck()
Checks if CSRF token has been tampered with.
array|string
get(string|null $input = null)
Supports operations related to handling POST and GET requests.
void
jsonError(string $message, int $status = 400, array $errors = [])
Makes JSON Response for error payloads.
void
jsonResponse(mixed $data, int $status = 200, array $extraHeaders = [])
Sends a JSON response with headers and status code.
void
preflight()
Respond to CORS preflight.
Details
at line 20
bool
apiCsrfCheck()
Checks if CSRF token has been tampered with.
at line 35
array|string
get(string|null $input = null)
Supports operations related to handling POST and GET requests.
Similar in behavior to the get function from the Input class but for JSON related operations.
at line 69
void
jsonError(string $message, int $status = 400, array $errors = [])
Makes JSON Response for error payloads.
at line 84
void
jsonResponse(mixed $data, int $status = 200, array $extraHeaders = [])
Sends a JSON response with headers and status code.
at line 117
void
preflight()
Respond to CORS preflight.