GithubHelp home page GithubHelp logo

Comments (14)

masterix21 avatar masterix21 commented on June 17, 2024 3

@aminraeisi try something like this:

class SwitchTenantTelescopeTask implements SwitchTenantTask
{
    protected ?array $originalTelescopeTagUsing;

    public function makeCurrent(Tenant $tenant): void
    {
        $this->originalTelescopeTagUsing = Telescope::$tagUsing;

        Telescope::$tagUsing = [];
        Telescope::tag(fn () => [ $tenant->domain ]);
    }

    public function forgetCurrent(): void
    {
        Telescope::$tagUsing = $this->originalTelescopeTagUsing;
        Telescope::tag(fn () => [ 'landlord' ]);
    }
}

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024 1

My suggestion is to keep working telescope on the landlord connection. Next, create a tag for Telescope when you switch a tenant.

I will create a TelescopeSwitchTenantTask in the next PR, and I hope that will be merged.

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

@masterix21 thanks! I will wait for that 😄

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

Thanks for your time! What does this supposed to do? is it for tagging the telescope entries (assuming I need to move the telescope migrations to landlord)?

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024

Yes!

I think that the best way to use Telescope is in only one database (landlord), then when you need to track a request or anything else about a Tenant, you can simply add a "tag" to Telescope. Will works like a charm :)

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

It worked! Please update $tenant->host to $tenant->domain as it made me spend 1 hour to find out why it is not tagging them 🤣

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024

Haha, sorry, I made a mistake because I'm using "host" and not "domain" in my project.

Thanks.

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

Thanks for that! one more thing, It did not tag the non-tenant requests. I can put space to detect them but it would be better if the default is landlord.

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024

Doesn't works using "landlord" as tag?

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

Each tenant has subdomain and visiting tenant1.site.com will tag the request with tenant1.site.com but when I go to the main site.com the request does not get any tags and I want to get 'landlord' tag for it.

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024

Ok. What happen if you add Telescope::tag(fn () => [ 'landlord' ]); to your AppServiceProvider boot method?

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

That adds the landlord tag to all the requests even if it is a tenant request. So I need to remove it somehow when it is on the tenant? Or we don't have tasks to run when no tenant is selected? I mean when the request is to the main landlord site?

from laravel-multitenancy.

aminraeisi avatar aminraeisi commented on June 17, 2024

Adding this to AppServiceProvider worked:

!Tenant::current() ? Telescope::tag(fn () => ['landlord']): '';

So it will only add the landlord tag if we do not have a current tenant. Thanks a lot for your help.

from laravel-multitenancy.

masterix21 avatar masterix21 commented on June 17, 2024

Well ;)

from laravel-multitenancy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.