public function status($value = null)
{
if ($value !== null) {
$this->status = $value;
return $this;
}
if ($this->status) {
return $this->status;
}
// There was no status so loop through the errors and look for the highest one.
$maxStatus = 400;
foreach ($this->errors as $field => $errors) {
foreach ($errors as $error) {
if (isset($error['status']) && $error['status'] > $maxStatus) {
$maxStatus = $error['status'];
}
}
}
return $maxStatus;
}
/** * Initialize an instance of the {@link ValidationException} class. * * @param Validation $validation The {@link Validation} object for the exception. */ public function __construct(Validation $validation) { $this->validation = $validation; parent::__construct($validation->getMessage(), (int) $validation->status()); }