Authored by ziy

添加方法first

... ... @@ -63,11 +63,27 @@ class Messages
* 判断是否有错误信息
* @return bool
*/
public function has()
public function has($key = null)
{
if ($key == null) {
return count($this->messages) > 0;
}
return isset($this->messages[$key]);
}
/**
* 第一个错误
* @param $key
* @return array
*/
public function first($key)
{
if (isset($this->messages[$key])) {
return $this->messages[$key][0];
}
return '';
}
public function getMessages($key, $type = null)
{
if (isset($this->customMessages[$key])) {
... ...