25 lines
575 B
PHP
25 lines
575 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Exception;
|
|
use Illuminate\Contracts\Validation\Validator;
|
|
use App\Responses\BaseResponse;
|
|
|
|
class BaseException extends Exception {
|
|
|
|
protected $validator;
|
|
|
|
protected $code = 422;
|
|
|
|
public function __construct(Validator $validator) {
|
|
$this->validator = $validator;
|
|
}
|
|
|
|
public function render() {
|
|
$response = new BaseResponse();
|
|
$response->setMessage($this->validator->errors()->first());
|
|
$response->setStatus("KO");
|
|
return response()->json($response, $this->code);
|
|
}
|
|
} |