public function CreateShop($ssid) { $shop = new Shop(); $shop->title = \Yii::t('app', 'Main Shop'); $shop->description = \Yii::t('app', 'Generated by system Automatically'); $shop->ssid = $ssid; $shop->status = 0; // Status Open if ($shop->save(true)) { return $shop->id; } else { return false; } }
public static function getShopName($shopId) { $shopObj = Shop::findOne(['id' => $shopId]); if (!empty((array) $shopObj)) { // check an object is empty return $shopObj->title; } }
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; } } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Shop::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' => helper::getSsid(), 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getShop() { return $this->hasOne(Shop::className(), ['id' => 'shop_id']); }