Collection.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\User\Model\ResourceModel\User;
  7. /**
  8. * Admin user collection
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  14. {
  15. /**
  16. * Define resource model
  17. *
  18. * @return void
  19. */
  20. protected function _construct()
  21. {
  22. $this->_init(\Magento\User\Model\User::class, \Magento\User\Model\ResourceModel\User::class);
  23. }
  24. /**
  25. * Collection Init Select
  26. *
  27. * @return $this
  28. * @since 101.1.0
  29. */
  30. protected function _initSelect()
  31. {
  32. parent::_initSelect();
  33. $this->getSelect()->joinLeft(
  34. ['user_role' => $this->getTable('authorization_role')],
  35. 'main_table.user_id = user_role.user_id AND user_role.parent_id != 0',
  36. []
  37. )->joinLeft(
  38. ['detail_role' => $this->getTable('authorization_role')],
  39. 'user_role.parent_id = detail_role.role_id',
  40. ['role_name']
  41. );
  42. }
  43. }