コード例 #1
0
ファイル: NewUserSetup.php プロジェクト: best-nazar/gb-yii2
 public function CreateAdmin($shopId, $ssid)
 {
     if ($shopId != null && $shopId != 0) {
         $manager = new Manager();
         $manager->ssid = $ssid;
         $manager->user_id = $ssid;
         $manager->title = 'Admin';
         $manager->description = \Yii::t('app', 'Generated by system Automatically');
         $manager->shop_id = $shopId;
     }
     if ($manager->save(true)) {
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: Manager.php プロジェクト: best-nazar/gb-yii2
 public static function deleteManager($id)
 {
     $manager = Manager::findOne($id);
     if ($manager->delete()) {
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: shopHelper.php プロジェクト: best-nazar/gb-yii2
 public static function getCurrShop()
 {
     $manager = Manager::findOne(['user_id' => Yii::$app->user->id]);
     if ($manager) {
         $shop = Shop::findOne(['id' => $manager->shop_id]);
         if ($shop) {
             return $shop->title;
         }
     }
 }
コード例 #4
0
ファイル: managerSearch.php プロジェクト: best-nazar/gb-yii2
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * example :
  * $managerSearch = new managerSearch();
  *  return $this->render('view', [
  * 'model' => $this->findModel($id),
  * 'relatedManagers' => $managerSearch->search([$managerSearch->formName()=>['shop_id'=>$id]])
  * ]);
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Manager::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'ssid' => $this->ssid, 'shop_id' => $this->shop_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: helper.php プロジェクト: best-nazar/gb-yii2
 public static function showShopID()
 {
     $manager = Manager::findOne(['user_id' => Yii::$app->user->id]);
     if ($manager) {
         return $manager->shop_id;
     }
 }
コード例 #6
0
 public static function getUserID($id)
 {
     $manager = Manager::findOne($id);
     if ($manager) {
         $user = User::findOne($manager->user_id);
         if ($user) {
             return $user->id;
         }
     } else {
         return false;
     }
 }
コード例 #7
0
 /**
  * Finds the Manager model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Manager the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Manager::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #8
0
ファイル: Shop.php プロジェクト: best-nazar/gb-yii2
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getManagers()
 {
     return $this->hasMany(Manager::className(), ['shop_id' => 'id']);
 }