Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting multiple auth #397

Open
koushik355 opened this issue Aug 3, 2021 · 1 comment
Open

Supporting multiple auth #397

koushik355 opened this issue Aug 3, 2021 · 1 comment

Comments

@koushik355
Copy link

koushik355 commented Aug 3, 2021

Hi, thank you for such a wonderful package. Definitely made life a lot easier.
I've multiple auth in my application.

'providers' => [
        'staff' => [
            'driver' => 'eloquent',
            'model' => App\Models\Staff::class,
        ],

        'users' => [
            'driver' => 'eloquent',
            'model' => App\Models\User::class,
        ],
],

Is there anyway to support multi auth? The problem is that a model can be edited by the user and the staff as well. However, just by the id, it's not possible to track who actually edited it.

Is it possible to event return the id of the Revision model in the event listening?
I checked it and it doesn't return the id of the Revision (revision id from revisions table)
I tried tracking the event like this.

Event::listen('revisionable.*', function ($model, $revisions) {
            // Do something with the revisions or the changed model.
//            Log::info(json_encode($revisions)); // couldn't get the Revision model id here
});

If I can just get to know the revision id, I can update the table manually with something like this

if (Auth::check()) {
    $revisionId = 'id here';
    Revision::where('id', $revisionId)->update('user_type' => Auth::user() instance of User ? 'user' : 'staff');
}

Please let me know if it's possible to get the id in the revision event. That would be do my work. Thank you very much in advance.

@DrowningElysium
Copy link

DrowningElysium commented Apr 17, 2023

I would love if the user_id could be replaced with a morph option:

authable_type = \App\Models\User
authable_id = 1
authable_type = \App\Models\Client
authable_id = 1

Would firstly work for any situation. Secondly it would allow for a eager loadable relation, which is currently not the case.
A timeline would need to do n+1 queries to list who did what. Which I think is not desired.

This would be a breaking change. But I do think one for the better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants