select('ta.id, ta.name, tt.title, tlog.tmc, tlog.issue_date') ->from(\app\models\entity\UserDevice::tableName() . ' tu') ->leftJoin(\app\models\entity\Log::tableName() . ' tlog', 'tlog.id = tu.camera OR tlog.id = tu.oil_meter OR tlog.id = tu.phone') ->leftJoin(\app\models\entity\Accounts::tableName() . ' ta', 'ta.id = tlog.employee') ->leftJoin(\app\models\entity\Tmc::tableName() . ' tt', 'tt.id = tlog.tmc') ; $result = $query->all(); //[userId => deviceInfo[]] $userDevices = []; foreach ($result as $device) { $userDevices[$device['id']][] = $device; } ?>
Список устройств у сотрудников » Принять устройство