am using mdmsoft / yii2-admin plugin is there any way to get user ids who has access/permission to specific route. I need to show only those user who can access the specific action in a dropdown.
Before I was doing this but I want this dynamic based on Helper::checkRoute() method
$usersProfiles = UserProfile::find()->all();
$authAssignmentHeadUserIds = AuthAssignment::find()
->orWhere(['item_name' => 'marketing-head'])
->orWhere(['item_name' => 'media-head'])
->orWhere(['item_name' => 'production-head'])
->select(['user_id'])
->all();
$userHeadProfiles = UserProfile::find()
->where(['in', 'user_id', $authAssignmentHeadUserIds])->all();
I was able to fetch user ids for routes
//Getting parent roles which had access to route
$authItemParentRoles = AuthItemChild::find()
->where(['child' => '/voucher/accept'])
->orWhere(['child' => '/voucher/*'])
->select(['parent'])
->asArray()
->all();
//Extracting parent role onlys from given array.
$parentRoleArray = array_column($authItemParentRoles, 'parent');
//Extracting user ids whose role is in parent role array
$usersHavingAccess = AuthAssignment::find()
->where(['in', 'item_name', $parentRoleArray])
->select(['user_id'])->all();
//Lastly fetching profile or users having access to that route.
$userHeadProfiles = UserProfile::find()
->where(['in', 'user_id', $usersHavingAccess])->all();
Thanks to Shringiraj Dewangan who used array column in his answer, that was the missing piece