PHP code example of datakrama / lapires
1. Go to this page and download the library: Download datakrama/lapires 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/ */
datakrama / lapires example snippets
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Datakrama\Lapires\Traits\ApiResponser;
class HomeController extends Controller
{
use ApiResponser;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
return view('home');
}
/**
* Success response
*
* @return void
*/
public function success()
{
$data = ['foo' => 'bar'];
$message = 'This is example success response.';
$code = 200;
return $this->successResponse($data, $message, $code);
}
/**
* Error response
*
* @return void
*/
public function error()
{
$code = 500;
$message = 'This is example error response.';
$errors = ['foo' => 'bar'];
return $this->successResponse($code, $message, $errors);
}
}