1. Go to this page and download the library: Download horcrux/handleresponse library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Http\Controllers;
use Horcrux\Handleresponse\Core\Traits\LaravelResponse;
use Illuminate\Http\Request;
class TestController extends Controller
{
use LaravelResponse;
public function index()
{
return $this->senddata([152 , 'one']);
}
}
return $this->senderror([258 , 'user is not found'])
return $this->senderror([258 , 'user is not found'],500);
// response will return with 500 status code
return $this->senderror([258 , 'user is not found'],500 , 'other_driver');
$this->change_driver('other_driver');
return $this->senderror([258 , 'user is not found']);