request->get('userId'); $query = new \yii\db\Query(); $query->select('tlog.tmc, t.employee as user, ttmc.title, tlog.issue_date') ->from(\app\models\entity\UserDevice::tableName() . ' t') ->leftJoin(\app\models\entity\Log::tableName() . ' tlog', 't.phone = tlog.id or t.camera = tlog.id or t.oil_meter = tlog.id') ->leftJoin(\app\models\entity\Tmc::tableName() . ' ttmc', 'ttmc.id = tlog.tmc') ->where(['t.employee' => $userId]) ; $devices = $query->all(); ?>
Выданные устройства:

Пользователю не выдано устройств