/** * Create store and store locations in mongoDB */ public function actionCreate() { $params = $this->getParams(); $store = new Store(); $store->attributes = $params; $store->_id = new MongoId(); $token = Token::getToken(); $store->accountId = $token->accountId; if ($store->validate()) { // all inputs are valid if ($store->save()) { $location = $store->location; unset($location['deatail']); $args = ['location' => $location, 'storeId' => $store->_id . '', 'accountId' => $store->accountId . '', 'description' => 'Direct: Create store locations in storeLocation collection']; // create a to create store locations Yii::$app->job->create('backend\\modules\\member\\job\\Location', $args); return $store; } else { throw new ServerErrorHttpException(Yii::t('common', 'save_fail')); } } else { // valid fail, return errors return $store->errors; } }