Repository navigation
Output REST Web Services
The base route it /_eon_phpstencil/api/rest.
To create your own routes, place them in the routes_rest.php file under the src/Factories/WebService/Routes/ directory.
Create your controller in the src/Factories/WebService/REST/Controllers and extend the RestBaseController class.
Extending this class will give you access to two methods:
- return_success
- return_error
The return_success method has two parameters. $messages and $more_data. The second parameter is optional.
You can pass through any success messages you like for the $messages parameter, and then any data you wish to present alongside the response with the $more_data parameter.
Note: Both $messages and $more_data are arrays.
The return_error method only accepts one parameter. $messeges is an array that will hold all error messages in your response.
To return content to the user (from the controller), you need to wrap the return_success and return_error methods in a json response. Like this:
return response()->json($this->return_error(['Item does not exist.'])); // request error
return response()->json($this->return_success(['Item deleted.'])); // request successful