store\controllers\PurchaseController::actionIndex PHP Method

actionIndex() public method

public actionIndex ( )
    public function actionIndex()
    {
        $createApplyForm = new CreateApplyForm();
        if (Yii::$app->request->isPost && $createApplyForm->load(Yii::$app->request->post())) {
            try {
                if ($createApplyForm->create()) {
                    Yii::$app->session->setFlash('success', '采购申请已创建成功,请您耐心等待,申请结果将发送至您店铺中的手机号上。');
                    return $this->redirect(['/apply/view', 'id' => $createApplyForm->apply->id]);
                } else {
                    Yii::$app->session->setFlash('danger', '采购申请创建失败。');
                }
            } catch (\Exception $e) {
                Yii::$app->session->setFlash('danger', $e->getMessage());
            }
        }
        return $this->render('index', ['createApplyForm' => $createApplyForm]);
    }