request->get('userId'); $query = new Query(); $query->select('tlog.tmc, tt.title as device, tlog.issue_date') ->from(UserDevice::tableName() . ' tud') ->leftJoin(Log::tableName() . ' tlog', 'tlog.id = tud.camera or tlog.id = tud.oil_meter or tlog.id = tud.phone') ->leftJoin(Tmc::tableName(). ' tt', 'tlog.tmc = tt.id') ->where(['tud.employee' => $userId]) ; $devices = $query->all(); foreach ($devices as $device): ?>