qrValidators as $qrValidator) { $partner_ids[] = $qrValidator->partner_id; } if (sizeof($partner_ids) > 0) { //$articles->innerJoinWith('events'); $events = \app\models\Events::find(); $condition = ['and']; $condition[] = ['=', 'type', 'booking']; $condition[] = ['IN', 'partner_id', $partner_ids]; $events->where($condition); $data = []; foreach ($events->all() as $event) { $data[] = [ 'id' => $event->id, 'name' => $event->title(), 'date' => date('d.m.Y', strtotime($event->event_dates))]; } echo json_encode(['data' => $data]); exit; } } /* @var $this \yii\web\View */