laratrust icon indicating copy to clipboard operation
laratrust copied to clipboard

Laravel 8 jetstram Teams

Open GeoSot opened this issue 3 years ago • 5 comments

Hello @santigarcor

Along with the laravel 8, jetstream package is introduced as default, to handle authentication functionality.

As I have seen, it brings teams functionality, which bring new variables on the table.

I would like to ask if you are aware of it and if you have thought any way to combine or separate the two teams (yours and jetstream) Models and functionality

GeoSot avatar Sep 09 '20 14:09 GeoSot

@GeoSot I saw Taylor's talk about it, and to be honest I haven't thought about combining them. But it would be the way to go.

I believe some hacky solution(for now) would be to change all the Laratrust's configurations to use jetstream's teams table and model, but leaving the intermediate tables as they are.

santigarcor avatar Sep 09 '20 14:09 santigarcor

@GeoSot I saw Taylor's talk about it, and to be honest I haven't thought about combining them. But it would be the way to go.

I believe some hacky solution(for now) would be to change all the Laratrust's configurations to use jetstream's teams table and model, but leaving the intermediate tables as they are.

Tried to this but got this error here:

Trait method Laratrust\Traits\LaratrustUserTrait::allTeams has not been applied as App\Models\User::allTeams, because of collision with Laravel\Jetstream\HasTeams::allTeams

so did this:

    use LaratrustUserTrait {
        LaratrustUserTrait::allTeams insteadof HasTeams;
    }

Seems to be working so far.

jigzstar avatar Jan 07 '21 21:01 jigzstar

Hi @santigarcor , I believe that I'm having some other error related to teams of jetstream.

While learning about laratrust and exactly on this point of the docs: https://laratrust.santigarcor.me/docs/6.x/usage/roles-and-permissions.html#assignment-2 , I'm receiving this error while testing it:

image

Well, the error is quite logic, but I'm afraid that the laratrust install didnt make the right modification on migrations, because this field doesnt exists on migration file...

If I create this field on role_user table, maybe the error go away but it's the right way to fix it?

Thanks

patake avatar Mar 03 '21 21:03 patake

@GeoSot I saw Taylor's talk about it, and to be honest I haven't thought about combining them. But it would be the way to go. I believe some hacky solution(for now) would be to change all the Laratrust's configurations to use jetstream's teams table and model, but leaving the intermediate tables as they are.

Tried to this but got this error here:

Trait method Laratrust\Traits\LaratrustUserTrait::allTeams has not been applied as App\Models\User::allTeams, because of collision with Laravel\Jetstream\HasTeams::allTeams

so did this:

    use LaratrustUserTrait {
        LaratrustUserTrait::allTeams insteadof HasTeams;
    }

Seems to be working so far.

Do you have an example of how you added laratrust support inline with jetstream teams? I was going to use spatie permissions but actually need laratrusts individual based user team permissions and hit a wall with the jetstreams clash.

tonypartridger avatar Jun 29 '22 15:06 tonypartridger

To be honest, I kept laratrust for my simple projects, and for some demanding projects, I implemented a custom-made hybrid using fortify for authentication, and a combination of jetstream & laratrust for authorization 😞

GeoSot avatar Jun 29 '22 19:06 GeoSot