예제 #1
0
 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
 public static function deleteManager($id)
 {
     $manager = Manager::findOne($id);
     if ($manager->delete()) {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 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
 /**
  * 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
 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;
     }
 }
 /**
  * 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']);
 }