ApiResponse
trait ApiResponse
ApiResponse trait
Properties
protected array | $result | Response result | |
protected bool | $prettyFormat | pretty format json |
Methods
ResponseInterface
getResponse(bool $raw = false)
Return response
ApiController
message(string $name)
Add message to response, first find in messages array if not found display name value as message
Self
field(string $name, mixed $value)
Set result field
Self
useJsonPrettyformat()
Set json pretty format to true
mixed
setResponse(bool $condition, array|string|Closure $data, string|string|Closure $error)
Set response
Self
setResult(mixed $data)
Set response result
void
clearResult()
Clear result
void
setResultField(string $name, mixed $value)
Set field to result array
void
setResultFields(array $values, string|null $filedName = null)
Set result filelds
string
getResponseJson(bool $raw = false)
Return json
Details
at line 37
ResponseInterface
getResponse(bool $raw = false)
Return response
at line 55
ApiController
message(string $name)
Add message to response, first find in messages array if not found display name value as message
at line 72
Self
field(string $name, mixed $value)
Set result field
at line 84
Self
useJsonPrettyformat()
Set json pretty format to true
at line 99
mixed
setResponse(bool $condition, array|string|Closure $data, string|string|Closure $error)
Set response
at line 124
Self
setResult(mixed $data)
Set response result
at line 136
void
clearResult()
Clear result
at line 153
void
setResultField(string $name, mixed $value)
Set field to result array
at line 165
void
setResultFields(array $values, string|null $filedName = null)
Set result filelds
at line 182
string
getResponseJson(bool $raw = false)
Return json