예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Store::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['store_id' => $this->store_id, 'group_id' => $this->group_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['store_id', 'order_status_id', 'payment_status_id', 'shipping_method_id', 'payment_method_id'], 'default'], ['store_id', 'default', 'value' => Yii::$app->settings->get('orderDefaults.store_id')], ['order_status_id', 'default', 'value' => Yii::$app->settings->get('orderDefaults.order_status_id')], ['payment_status_id', 'default', 'value' => Yii::$app->settings->get('orderDefaults.payment_status_id')], ['shipping_method_id', 'default', 'value' => Yii::$app->settings->get('orderDefaults.shipping_method_id')], ['payment_method_id', 'default', 'value' => Yii::$app->settings->get('orderDefaults.PaymentMethod')], [['store_id', 'invoice_no'], 'required', 'on' => ['create', 'safeEdit']], ['store_id', 'in', 'range' => Store::find()->select('store_id')->asArray()->column()], ['payment_method_id', 'in', 'range' => PaymentMethod::find()->select('payment_method_id')->asArray()->column()], ['order_status_id', 'in', 'range' => OrderStatus::find()->select('order_status_id')->asArray()->column()], ['payment_status_id', 'in', 'range' => PaymentStatus::find()->select('payment_status_id')->asArray()->column()], ['shipping_method_id', 'in', 'range' => ShippingMethod::find()->select('shipping_method_id')->asArray()->column()], ['payment_method_id', 'in', 'range' => PaymentMethod::find()->select('payment_method_id')->asArray()->column()], [['order_status_id', 'create_by', 'status'], 'integer'], [['payment_text', 'shipping_text', 'comment'], 'string'], [['purchase_price', 'shipping_price', 'total_price', 'sale_price'], 'number'], [['create_time', 'update_time'], 'safe'], [['invoice_no'], 'string', 'max' => 128], [['shipping_tracking'], 'string', 'max' => 256], [['ip'], 'string', 'max' => 40], [['user_agent'], 'string', 'max' => 255]];
 }
예제 #3
0
 private function getStoreQueryByUserId($user_id)
 {
     if ($user_id == 0) {
         $user_id = Yii::$app->user->id;
     }
     return Store::find()->joinWith('users')->where(['user.id' => $user_id])->with(['orderStatuses'])->all();
 }