Getting all users data? #1406

Closed
opened 2026-02-05 00:48:49 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @dingo-d on GitHub (Oct 13, 2019).

I'm trying to implement a 'page review', so I've added a 'review' sidebar part on the page. My idea is to have a list of users that are in the 'Reviewer' group I've created so that I can add them to review the content on page save.

I've never worked with BookStack app before, and I'm searching for some method that will allow me to list all the users and then filter them, but no luck so far.

I've found getAllUsers() method in the UserRepo class, but I'm not sure how to use it inside my views.

I can access user() method, but this will only provide me with the currently logged in user.

Any help is appreciated.

Originally created by @dingo-d on GitHub (Oct 13, 2019). I'm trying to implement a 'page review', so I've added a 'review' sidebar part on the page. My idea is to have a list of users that are in the 'Reviewer' group I've created so that I can add them to review the content on page save. I've never worked with BookStack app before, and I'm searching for some method that will allow me to list all the users and then filter them, but no luck so far. I've found `getAllUsers()` method in the `UserRepo` class, but I'm not sure how to use it inside my views. I can access `user()` method, but this will only provide me with the currently logged in user. Any help is appreciated.
Author
Owner

@ssddanbrown commented on GitHub (Oct 13, 2019):

Hi @dingo-d,
You could do something similar to below, Querying the role you want then getting the users:

    @foreach(\BookStack\Auth\Role::query()->where('name', '=', 'admin')->first()->users as $user)
        <div>
            <strong>{{ $user->id }}</strong>
            {{ $user->name }}
        </div>
    @endforeach

You'd need to change admin to the name of the role in the DB.
BookStack users Laravel so those docs may provide more info.

Note though, any of these kind of app code usages or these kind of customizations/modifications are not supported as part of the BookStack project and may cause you trouble during upgrades.

@ssddanbrown commented on GitHub (Oct 13, 2019): Hi @dingo-d, You could do something similar to below, Querying the role you want then getting the users: ```php @foreach(\BookStack\Auth\Role::query()->where('name', '=', 'admin')->first()->users as $user) <div> <strong>{{ $user->id }}</strong> {{ $user->name }} </div> @endforeach ``` You'd need to change `admin` to the name of the role in the DB. BookStack users Laravel so [those docs](https://laravel.com/docs/5.5/eloquent#retrieving-models) may provide more info. Note though, any of these kind of app code usages or these kind of customizations/modifications are not supported as part of the BookStack project and may cause you trouble during upgrades.
Author
Owner

@dingo-d commented on GitHub (Oct 13, 2019):

Yeah, this is something a bit specific so I'll have to be careful about the updates in the future.
I'll look into the code a bit more while implementing it. Thanks for the answer!

@dingo-d commented on GitHub (Oct 13, 2019): Yeah, this is something a bit specific so I'll have to be careful about the updates in the future. I'll look into the code a bit more while implementing it. Thanks for the answer!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1406