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

I cant get tenant from User Model and make this work with Observer #42

Closed
jcastroa87 opened this issue Oct 6, 2021 · 1 comment
Closed

Comments

@jcastroa87
Copy link

Hello, first thanks for this package.

I have this scenario:

i Have this Middleware: \App\Http\Middleware\Tenant::class, i get tenant id from user Model

public function handle(Request $request, Closure $next)
{
    if( Schema::hasTable('tenants') ) {
        if (auth()->check()) {
            $tenant = app('rinvex.tenants.tenant')->find(backpack_user()->tenants());
        } else {
            $tenant = null;
        }

        app()->singleton('request.tenant', fn() => $tenant); // setear null si se quiere ver todo
    }

    return $next($request);
}

This work for almost everything, except when i use Observer, is look like when Observer is add this make laravel execute models before middleware, and thats make ignore the scope.

How can i make this: get id from user model and make this package work with observer?

Thanks in advance.

@Omranic
Copy link
Member

Omranic commented Oct 10, 2021

Based on the email discussion we had earlier, my understanding is that you've solved this issue. Happy it's working now 🙂

Feel free to re-open if you need further help.

@Omranic Omranic closed this as completed Oct 10, 2021
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