@@ -34,9 +34,17 @@ php artisan vendor:publish --provider="Lykegenes\ApiResponse\ServiceProvider" --
34
34
35
35
## Usage
36
36
37
+ The easiest way to use this package is to call the ** make()** function from the facade.
38
+ It will try to guess your input. For the transformers, see the docs from the Fractal package [ here] ( http://fractal.thephpleague.com/transformers/ ) .
37
39
``` php
38
- $skeleton = new Lykegenes\ApiResponse();
39
- echo $skeleton->echoPhrase('Hello, Lykegenes!');
40
+ // You can use a class directly to return a paginated collection
41
+ return ApiResponse::make(User::class, UserTransformer::class);
42
+
43
+ // You can also use an Eloquent Query
44
+ return ApiResponse::make(User::where('age', '<', '40'), UserTransformer::class);
45
+
46
+ // This will return a single object
47
+ return ApiResponse::make(User::findOrFail($id), UserTransformer::class);
40
48
```
41
49
42
50
## Testing
@@ -62,7 +70,7 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
62
70
[ ico-downloads ] : https://img.shields.io/packagist/dt/lykegenes/laravel-api-response.svg?style=flat-square
63
71
64
72
[ link-packagist ] : https://packagist.org/packages/lykegenes/laravel-api-response
65
- [ link-travis ] : https://travis-ci.org/lykegenes /laravel-api-response
73
+ [ link-travis ] : https://travis-ci.org/Lykegenes /laravel-api-response
66
74
[ link-scrutinizer ] : https://scrutinizer-ci.com/g/lykegenes/laravel-api-response/code-structure
67
75
[ link-code-quality ] : https://scrutinizer-ci.com/g/lykegenes/laravel-api-response
68
76
[ link-downloads ] : https://packagist.org/packages/lykegenes/laravel-api-response
0 commit comments