/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Call::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
public static function badgeAllCount($modelName) { $count = 0; switch ($modelName) { case 'Order': $count = Order::find()->count(); break; case 'Call': $count = Call::find()->count(); break; case 'Review': $count = Review::find()->count(); break; default: $count = 0; break; } $options = ['class' => 'badge']; if ($count) { return Html::tag('span', $count, $options); } return Html::tag('span', $count, $options); }
public static function badges($modelName) { $count = 0; switch ($modelName) { case 'Order': $count = Order::find()->where(['status' => Order::STATUS_NEW])->count(); break; case 'Call': $count = Call::find()->where(['status' => Call::STATUS_NEW])->count(); break; case 'Review': $count = Review::find()->where(['status' => Review::STATUS_NEW])->count(); break; default: $count = 0; break; } $options = ['class' => 'label-danger label-as-badge']; if ($count) { return Html::tag('span', $count, $options); } $options = ['class' => 'label-info label-as-badge']; return Html::tag('span', $count, $options); }