PHP code example of ckryo / laravel_expand

1. Go to this page and download the library: Download ckryo/laravel_expand 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/ */

    

ckryo / laravel_expand example snippets


php artisan vendor:publish

$errCodes = rrCodes as $model => $codes) {
    $errorCode->regist($model, $codes);
}



namespace Ckryo\Laravel\Handler;

use Ckryo\Laravel\Handler\Contracts\ExceptionFactory;
use Ckryo\Laravel\Handler\Facades\ErrorCode;

class ErrorCodeException extends \Exception implements ExceptionFactory
{
    protected $code;
    protected $message;
    protected $data;

    public function __construct($code, $message = null, $data = null)
    {
        $this->code = $code;
        $this->data = $data ?: $this;
        $this->message = $message ?: ErrorCode::getErrMsg($code);
    }

    public function handle()
    {
        return response()->json([
            'errCode' => $this->code,
            'errMsg' => $this->message,
            'data' => $this->data
        ]);
    }
}