Init
This commit is contained in:
25
app/Exceptions/BaseException.php
Normal file
25
app/Exceptions/BaseException.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user