我写了这个可以添加到User类的函数.
原文链接:https://www.f2er.com/php/132757.html/** * Finds all users by assignment role * * @param \yii\rbac\Role $role * @return static|null */ public static function findByRole($role) { return static::find() ->join('LEFT JOIN','auth_assignment','auth_assignment.user_id = id') ->where(['auth_assignment.item_name' => $role->name]) ->all(); }