public function to_array($closure = null)
{
$errors = array();
if ($this->errors) {
foreach ($this->errors as $attribute => $messages) {
foreach ($messages as $msg) {
if (is_null($msg)) {
continue;
}
$errors[$attribute][] = $message = Utils::human_attribute($attribute) . ' ' . $msg;
if ($closure) {
$closure($attribute, $message);
}
}
}
}
return $errors;
}