Skip to main content

抛异常

控制器中

throw new \Exception('请求异常');

throw new \yii\base\Exception(package days不能小于1)

来自 <https://www.it1352.com/743662.html> 

模型层

    public function beforeSave($insert)
    {
        $app = new TosanAdapay($this->memberId);

        if ($this->statusAdapay != 3){
            $this->addError('reason', $this->reason);
            return false;
        }
        return parent::beforeSave($insert); // TODO: Change the autogenerated stub
    }