/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Activities::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, 'user_id' => $this->user_id, 'time' => $this->time]); $query->andFilterWhere(['like', 'activity', $this->activity])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'status', $this->status]); 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; }
/* @var $this yii\web\View */ use yii\helpers\Html; use yii\helpers\Url; use common\models\Activities; use frontend\widgets\ActivityBox; ?> <!-- MY EVENTS --> <div class="featured"> <h2 style="text-align:center; margin:30px 0 10px 0;">Moj market</h2> <hr> <p class="paragraph" style="text-align:center; margin:0 0 10px 0; color:#aaa; font-size:11px;"><?php echo Yii::t('app', 'Choose category by clicking on the colored boxes and then select one of the service industry from the list below.'); ?> </p> <?php foreach (Activities::find()->limit(5)->all() as $key => $activity) { echo ActivityBox::widget(['boxData' => []]); } // foreach ($sektor as $key=>$sek) ?> </div> <div class="show_more"><?php echo Html::a('POKAŽI JOŠ', Url::to('/market'), array('class' => 'btn btn-default')); ?> </div> <!-- LATEST --> <div class="featured"> <h2 style="text-align:center; margin:30px 0 10px 0;">Najnovije promene na marketu</h2> <hr> <p class="paragraph" style="text-align:center; margin:0 0 10px 0; color:#aaa; font-size:11px;"><?php