示例#1
0
 public function actionEdit($id)
 {
     $model = Shop::findOne($id);
     if ($model) {
         throw new NotFoundHttpException();
     }
     return $this->showForm($this->updateWithPostRequest($model));
 }
示例#2
0
 /**
  * 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]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'logo_img', $this->logo_img])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'working_time', $this->working_time])->andFilterWhere(['like', 'delivery', $this->delivery])->andFilterWhere(['like', 'phone_1', $this->phone_1])->andFilterWhere(['like', 'phone_2', $this->phone_2])->andFilterWhere(['like', 'phone_3', $this->phone_3])->andFilterWhere(['like', 'phone_4', $this->phone_4])->andFilterWhere(['like', 'phone_5', $this->phone_5])->andFilterWhere(['like', 'phone_6', $this->phone_6])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     $query = Shop::find();
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $sort = new Sort(['attributes' => ['id']]);
     $models = $query->orderBy($sort->orders)->offset($pages->offset)->limit($pages->limit)->all();
     # ----------
     $model = new Shop();
     $model->attributes = Yii::$app->request->post('searchForm');
     $dataProvider = new ActiveDataProvider(['query' => Shop::find(), 'pagination' => ['pageSize' => 2]]);
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'sort' => $sort, 'dataProvider' => $dataProvider, 'model' => $model]);
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getShop()
 {
     return $this->hasOne(Shop::className(), ['id' => 'shop_id']);
 }
示例#5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getShops()
 {
     return $this->hasMany(Shop::className(), ['category_id' => 'id']);
 }
示例#6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getShop()
 {
     return $this->hasOne(\common\models\Shop::className(), ['id' => 'shop_id']);
 }
示例#7
0
 /**
  * Finds the Shop model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Shop the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Shop::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#8
0
 public function rules()
 {
     return ArrayHelper::merge(parent::rules(), [[['shop_id', 'date'], 'required'], [['shop_id', 'is_live'], 'integer'], [['notes'], 'string'], [['image'], 'safe'], [['shop_id'], 'exist', 'skipOnError' => true, 'targetClass' => Shop::className(), 'targetAttribute' => ['shop_id' => 'id']], [['date'], 'date', 'format' => 'php:Y-m-d']]);
 }