/**
  * Creates a new ModerateShop model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ModerateShop();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
文件: Url.php 项目: nicdnepr/skidos
 public function addUrl($link)
 {
     $shop_id = null;
     $text = '';
     $profile = new Profile();
     $host = $profile->getHost($link);
     /* @var $shop Profile */
     $shop = Profile::find()->where(['host' => $host])->one();
     if ($shop) {
         $shop_id = $shop->user_id;
         $text .= 'магазин ' . $shop->url . '<br>';
         $text .= 'бонус покупателю ' . $shop->buyer_bonus . '<br>';
         $text .= 'бонус рекомендателю ' . $shop->recommender_bonus . '<br>';
         $text .= 'статус ' . $shop->status->name . '<br>';
     } elseif (!ModerateShop::find()->where(['url' => $host])->exists()) {
         $moderateShop = new ModerateShop(['user_id' => Yii::$app->user->identity->id, 'url' => $host]);
         $moderateShop->save();
     }
     $text .= 'Вы можете давать эту ссылку своим друзьям<br>';
     $url = new Url(['user_id' => Yii::$app->user->identity->id, 'link' => $link, 'shop_id' => $shop_id]);
     $url->save();
     return $text . \yii\helpers\Url::to(['purchase/create', 'affiliate_id' => Yii::$app->user->identity->id, 'url_id' => $url->id], true);
 }