src/Model/BaseModel.php
public function getFirstError($attribute = null)
    {
        if (!$this->errors) {
            return null;
        } elseif (is_null($attribute)) {
            $errors = $this->getErrors();
            reset($errors);
            $firstError = current($errors);
            $arrayKeys = array_keys($firstError);
            $error = $firstError[$arrayKeys[0]];
            return $error;
        }

        return parent::getFirstError($attribute);
    }
public function getFirstError($attribute = null)
    {
        if (!$this->errors) {
            return null;
        } elseif (is_null($attribute)) {
            $errors = $this->getErrors();
            reset($errors);
            $firstError = current($errors);
            $arrayKeys = array_keys($firstError);
            $error = $firstError[$arrayKeys[0]];
            return $error;
        }

        return parent::getFirstError($attribute);
    }
public function getFirstError ( $ attribute = null ) { if ( ! $ this -> errors ) { return null ; } elseif ( is_null ( $ attribute ) ) { $ errors = $ this -> getErrors ( ) ; reset ( $ errors ) ; $ firstError = current ( $ errors ) ; $ arrayKeys = array_keys ( $ firstError ) ; $ error = $ firstError [ $ arrayKeys [ 0 ] ] ; return $ error ; } return parent :: getFirstError ( $ attribute ) ; }
Returns the first error in the model
@author Olawale Lawal <wale@cottacush.com>
@param string $attribute
@return string
Returns the first error in the model