Skip to content
Discussion options

You must be logged in to vote

Hi Luis,

I am not sure if this is the best approach, I believe it's not enough for filtering by the relationship for example.

I have never used Spatie Roles, but I had a go with it:

    public function datasource(): ?Builder
    {
        return User::query()->with('roles');
    }

It's unclear to me if a user can have multiple roles.

Add($user->roles) shows me:

So, I follow this relationship, plucking the Roles names and joining them together by ",".

    public function addColumns(): ?PowerGridEloquent
    {
        return PowerGrid::eloquent()
            ->addColumn('id')
            ->addColumn('last_name')
            ->addColumn('role_name', function (User $user) {
                r…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by luis9430
Comment options

You must be logged in to vote
1 reply
@LinceIberico
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants