22 <img src="https://raw.githubusercontent.com/kolirt/laravel-api-response/3e46d9c25ba6e7fd096ec57c668125cb2ab985ce/image.svg">
33</p >
44
5- # Laravel Api Response
65
6+ # Laravel Api Response
77The package will help to generate json answers.
88
9- ## Installation
9+ <a href =" https://www.buymeacoffee.com/kolirt " target =" _blank " >
10+ <img src =" https://cdn.buymeacoffee.com/buttons/v2/arial-yellow.png " alt =" Buy Me A Coffee " style =" height : 60px !important ;width : 217px !important ;" >
11+ </a >
1012
13+
14+ ## Installation
1115```
1216$ composer require kolirt/laravel-api-response
1317```
1418
19+
1520## Example
1621Error response.
1722``` php
@@ -76,6 +81,7 @@ return api()
7681]
7782```
7883
84+
7985## Methods
8086
8187### error
@@ -84,18 +90,21 @@ Default response code 400.
8490return api()->error();
8591```
8692
93+
8794### success
8895Default response code 200.
8996``` php
9097return api()->success();
9198```
9299
100+
93101### setCode
94102Set custom response code. Available [ codes] ( https://en.wikipedia.org/wiki/List_of_HTTP_status_codes ) .
95103``` php
96104return api()->setCode($code);
97105```
98106
107+
99108### setDescription
100109Set description to response.
101110``` php
@@ -104,6 +113,7 @@ return api()->setDescription(['Description #1', 'Description #2']);
104113return api()->setDescription('Description');
105114```
106115
116+
107117### setErrors
108118Set description to response.
109119``` php
@@ -113,17 +123,20 @@ return api()->setErrors([
113123]);
114124```
115125
126+
116127### abort
117128``` php
118129return api()->abort('Error message', 400);
119130```
120131
132+
121133### cookie
122134Add cookie to response.
123135``` php
124136return api()->cookie(cookie('token', 'asdsadsadas', 60 * 3));
125137```
126138
139+
127140### setData
128141Set data to response.
129142``` php
@@ -136,4 +149,16 @@ return api()->setData('Data');
136149Render response.
137150``` php
138151return api()->render();
139- ```
152+ ```
153+
154+
155+ ## FAQ
156+ Check closed [ issues] ( https://github.com/kolirt/laravel-api-response/issues ) to get answers for most asked questions
157+
158+
159+ ## License
160+ [ MIT] ( LICENSE.txt )
161+
162+
163+ ## Other packages
164+ Check out my other packages on my [ GitHub profile] ( https://github.com/kolirt )
0 commit comments