jeybin/apiresponse

Laravel api response helper

v1.5 2023-01-11 08:30 UTC

This package is auto-updated.

Last update: 2024-05-11 16:23:57 UTC


README

Installation

You can install the package via composer:

  composer require jeybin/apiresponse

To publish providers and to copy the config files run :

  php artisan apiresponse:install

Usage

If you want to get the response as array you can use:

  \Jeybin\Apiresponse\ThrowResponse::status(200)
                              ->message('User defined message')
                              ->get(['can send array or string or empty'])

or else if you want to throw the response you can use:

  \Jeybin\Apiresponse\ThrowResponse::status(200)
                              ->message('User defined message')
                              ->throw(['can send array or string or empty'])

Without message

  \Jeybin\Apiresponse\ThrowResponse::status(200)
                              ->throw(['can send array or string or empty'])
  \Jeybin\Apiresponse\ThrowResponse::status('success')->throw()

Some of the status codes are already defined in the config/jeybin-apiresponse.php file, if you want to add more update that file