/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bids::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, 'activity_id' => $this->activity_id, 'offer_id' => $this->offer_id, 'order_id' => $this->order_id, 'loc_id' => $this->loc_id, 'period' => $this->period, 'period_unit' => $this->period_unit, 'delivery_starts' => $this->delivery_starts, 'price' => $this->price, 'currency_id' => $this->currency_id, 'price_per_unit' => $this->price_per_unit, 'fixed_price' => $this->fixed_price, 'warranty' => $this->warranty, 'time' => $this->time, 'hit_counter' => $this->hit_counter]); $query->andFilterWhere(['like', 'price_per', $this->price_per])->andFilterWhere(['like', 'note', $this->note])->andFilterWhere(['like', 'spec', $this->spec])->andFilterWhere(['like', 'reject_reason', $this->reject_reason])->andFilterWhere(['like', 'report_reason', $this->report_reason]); return $dataProvider; }
public function findBid($id) { if ($activity = \common\models\Activities::find()->where(['activity' => 'bid', 'user_id' => $id])->one()) { if ($bid = \common\models\Bids::find()->where(['activity_id' => $activity->id])->one()) { return $bid; } } return null; }