Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/novaday-co/laravel-api-response
This Package helps developers to easily make response for API
https://github.com/novaday-co/laravel-api-response
api easy-response laravel laravel-api laravel-response php php-api
Last synced: about 1 month ago
JSON representation
This Package helps developers to easily make response for API
- Host: GitHub
- URL: https://github.com/novaday-co/laravel-api-response
- Owner: novaday-co
- License: mit
- Created: 2021-02-20T12:09:56.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-03T04:19:16.000Z (over 3 years ago)
- Last Synced: 2024-04-21T03:08:43.287Z (8 months ago)
- Topics: api, easy-response, laravel, laravel-api, laravel-response, php, php-api
- Language: PHP
- Homepage: https://packagist.org/packages/novaday-co/laravel-api-response
- Size: 36.1 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Laravel API ResponseThis Package helps developers to easily make response for API . Add extra data to **collection** response . Short magic method that use your translate files to set messages .
----
## How to install :
```
composer require novaday-co/laravel-api-response
```## How to use :
### Success response
```php
Api::success("Successful Action")->response();
```### Success response
```php
Api::success("Successful Action")->response();
```### Failure response
```php
Api::failure("Failed")->response();
```### Custom response
```php
Api::customResponse(201,'Created Successfully',['key'=>'value'])->response();
```### With `data`
```php
Api::success('Ok',['key'=>'value'])->response();
```### External data in `data`
```php
Api::success('Ok',[ User::all() ])->withData([ Customer::first() ])->response();
```### External data next to `data`
```php
Api::success('Ok',[ User::all() ])->with([ 'Customers' => Customer::all() ])->response();
```### Short magic method for set messages
```php
Api::updated()->response();
```