Skip to content

Commit 8873aa7

Browse files
committed
Merge pull request #1 from Lykegenes/dev
Improve readme
2 parents 9eb2fdb + 33fe4ca commit 8873aa7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ php artisan vendor:publish --provider="Lykegenes\ApiResponse\ServiceProvider" --
3434

3535
## Usage
3636

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/).
3739
``` 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);
4048
```
4149

4250
## Testing
@@ -62,7 +70,7 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
6270
[ico-downloads]: https://img.shields.io/packagist/dt/lykegenes/laravel-api-response.svg?style=flat-square
6371

6472
[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
6674
[link-scrutinizer]: https://scrutinizer-ci.com/g/lykegenes/laravel-api-response/code-structure
6775
[link-code-quality]: https://scrutinizer-ci.com/g/lykegenes/laravel-api-response
6876
[link-downloads]: https://packagist.org/packages/lykegenes/laravel-api-response

0 commit comments

Comments
 (0)