Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

Laravel API Response package

# Laravel API Response

This 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();
```