You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 14, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+42Lines changed: 42 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,8 @@ Instead, you may of course manually update your require block and run `composer
70
70
71
71
Alright! Use `api_response()` helper.
72
72
73
+
[[ to top ]](#api-response)
74
+
73
75
74
76
## Using
75
77
@@ -84,6 +86,8 @@ return with code 304:
84
86
}
85
87
```
86
88
89
+
[[ to top ]](#api-response)
90
+
87
91
### as integer with default code:
88
92
```php
89
93
return api_response(304);
@@ -95,6 +99,8 @@ return with code 200:
95
99
}
96
100
```
97
101
102
+
[[ to top ]](#api-response)
103
+
98
104
### as string with default code:
99
105
```php
100
106
return api_response('qwerty');
@@ -106,6 +112,8 @@ return with code 200:
106
112
}
107
113
```
108
114
115
+
[[ to top ]](#api-response)
116
+
109
117
### as string with code:
110
118
```php
111
119
return api_response('qwerty', 400);
@@ -120,6 +128,8 @@ return with code 400:
120
128
}
121
129
```
122
130
131
+
[[ to top ]](#api-response)
132
+
123
133
### as integer with code:
124
134
```php
125
135
return api_response(304, 400);
@@ -134,6 +144,8 @@ return with code 400:
134
144
}
135
145
```
136
146
147
+
[[ to top ]](#api-response)
148
+
137
149
### as array:
138
150
```php
139
151
$data = [
@@ -148,6 +160,8 @@ $data = [
148
160
];
149
161
```
150
162
163
+
[[ to top ]](#api-response)
164
+
151
165
#### as error
152
166
```php
153
167
return api_response($data, 400);
@@ -171,6 +185,8 @@ return with code 400:
171
185
}
172
186
```
173
187
188
+
[[ to top ]](#api-response)
189
+
174
190
#### as success
175
191
```php
176
192
return api_response($data, 200);
@@ -193,6 +209,8 @@ return with code 200:
193
209
194
210
If the first parameter is a number, then the decryption of the error by code will be return. In other cases, the value of the passed variable will be return.
### as integer with default code and without `data` key:
272
294
```php
273
295
return api_response(304);
@@ -277,6 +299,8 @@ return with code 200:
277
299
304
278
300
```
279
301
302
+
[[ to top ]](#api-response)
303
+
280
304
### as string with default code and without `data` key:
281
305
```php
282
306
return api_response('qwerty');
@@ -286,6 +310,8 @@ return with code 200:
286
310
"qwerty"
287
311
```
288
312
313
+
[[ to top ]](#api-response)
314
+
289
315
### as string with code and without `data` key:
290
316
```php
291
317
return api_response('qwerty', 400);
@@ -300,6 +326,8 @@ return with code 400:
300
326
}
301
327
```
302
328
329
+
[[ to top ]](#api-response)
330
+
303
331
### as integer with code and without `data` key:
304
332
```php
305
333
return api_response(304, 400);
@@ -314,6 +342,8 @@ return with code 400:
314
342
}
315
343
```
316
344
345
+
[[ to top ]](#api-response)
346
+
317
347
### as array and without `data` key:
318
348
```php
319
349
$data = [
@@ -328,6 +358,8 @@ $data = [
328
358
];
329
359
```
330
360
361
+
[[ to top ]](#api-response)
362
+
331
363
#### as error and without `data` key
332
364
```php
333
365
return api_response($data, 400);
@@ -351,6 +383,8 @@ return with code 400:
351
383
}
352
384
```
353
385
386
+
[[ to top ]](#api-response)
387
+
354
388
#### as success and without `data` key
355
389
```php
356
390
return api_response($data, 200);
@@ -371,6 +405,8 @@ return with code 200:
371
405
372
406
If the first parameter is a number, then the decryption of the error by code will be return. In other cases, the value of the passed variable will be return.
373
407
408
+
[[ to top ]](#api-response)
409
+
374
410
### with additional content and without `data` key:
0 commit comments