public function search($params) { $query = Customer::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['customer_id' => $this->customer_id, 'store_id' => $this->store_id, 'address_id' => $this->address_id, 'active' => $this->active, 'create_date' => $this->create_date, 'last_update' => $this->last_update]); $query->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getCustomers() { return $this->hasMany(Customer::className(), ['store_id' => 'store_id']); }
/** * @return \yii\db\ActiveQuery */ public function getCustomer() { return $this->hasOne(Customer::className(), ['customer_id' => 'customer_id']); }
/** * Finds the Customer model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Customer the loaded model * @throws HttpException if the model cannot be found */ protected function findModel($id) { if (($model = Customer::findOne($id)) !== null) { return $model; } else { throw new HttpException(404, 'The requested page does not exist.'); } }