30 lines
685 B
PHP
30 lines
685 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Illuminate\Support\Arr;
|
|
use Slowlyo\OwlAdmin\Admin;
|
|
use Illuminate\Support\MessageBag;
|
|
use Slowlyo\OwlAdmin\Exceptions\AdminException;
|
|
|
|
class AdminValidationException extends AdminException
|
|
{
|
|
protected $errors;
|
|
|
|
public function __construct(MessageBag $error)
|
|
{
|
|
parent::__construct($error->first());
|
|
$errors = [];
|
|
foreach($error->messages() as $key => $messages) {
|
|
$errors[$key] = Arr::first($messages);
|
|
}
|
|
$this->errors = $errors;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return Admin::response()->additional(['errors' => $this->errors])->fail($this->getMessage());
|
|
}
|
|
|
|
}
|