eliseekn/laravel-api-response

Send JSON response from your API.

v0.0.4 2024-03-05 05:39 UTC

This package is auto-updated.

Last update: 2024-04-05 05:51:58 UTC


README

Latest Version on Packagist Total Downloads

Send JSON response from your API.

Installation

composer require eliseekn/laravel-api-response

Usage

Add MakeApiResponse trait where you need to use and use it as follows :

$this->response('success', 'Lorem ipsum dolor sit amet', 201);
$this->response('warning', [
    'key1' => 'value',
    'key2' => 'value'
], 405);

$this->successResponse('Lorem ipsum dolor sit amet');
$this->successResponse([
    'key1' => 'value',
    'key2' => 'value'
]);

$this->errorResponse(...);