1
0
mirror of https://github.com/flarum/core.git synced 2025-10-10 14:34:30 +02:00

Extract model validation into a trait

Also use Laravel’s ValidationException rather than our own custom one
This commit is contained in:
Toby Zerner
2015-07-05 12:25:08 +09:30
parent 04501545e3
commit 53e269fd89
11 changed files with 193 additions and 234 deletions

View File

@@ -1,68 +0,0 @@
<?php namespace Flarum\Core\Exceptions;
use Exception;
use Illuminate\Support\MessageBag;
use DomainException;
class ValidationFailureException extends DomainException
{
/**
* @var MessageBag
*/
protected $errors;
/**
* @var array
*/
protected $input = array();
/**
* @param string $message
* @param int $code
* @param Exception $previous
*/
public function __construct($message = '', $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
$this->errors = new MessageBag;
}
/**
* @param MessageBag $errors
* @return $this
*/
public function setErrors(MessageBag $errors)
{
$this->errors = $errors;
return $this;
}
/**
* @return MessageBag
*/
public function getErrors()
{
return $this->errors;
}
/**
* @param array $input
* @return $this
*/
public function setInput(array $input)
{
$this->input = $input;
return $this;
}
/**
* @return array
*/
public function getInput()
{
return $this->input;
}
}