Comments (14)
@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.
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.
@masterix21 thanks! I will wait for that 😄
from laravel-multitenancy.
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.
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.
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.
Haha, sorry, I made a mistake because I'm using "host" and not "domain" in my project.
Thanks.
from laravel-multitenancy.
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.
Doesn't works using "landlord" as tag?
from laravel-multitenancy.
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.
Ok. What happen if you add Telescope::tag(fn () => [ 'landlord' ]);
to your AppServiceProvider boot method?
from laravel-multitenancy.
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.
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.
Well ;)
from laravel-multitenancy.
Related Issues (20)
- Queue is not working after upgrading Laravel Framework to 9.34+
- SQL error when trying to use landlord database HOT 3
- Support for custom primary key on Tenant model HOT 1
- How can I access all tenant data at once?
- Tenant Not Set (Vapor + Octane) HOT 1
- Current tenant not determined when dispatching queued closures HOT 6
- When dispatching a Tenant Aware Job in sync mode from a test, any prior/current DB transaction is cleared HOT 2
- Model ignore tenant when add Observer HOT 2
- Tenant password reset token is being stored on landlord password_reset_tokens table HOT 1
- Prefixing cache doesn't work fine with file-store HOT 3
- Conflict with Rabbitmq package from vyuldashev HOT 1
- Scheduler : Large (longer) jobs, multiple tenants, stops.
- Tenant-Aware Job Scheduling with Horizon HOT 3
- MakeQueueTenantAwareAction seems to break active requests when Queue Connection is sync HOT 4
- base table or view not found with AWS SQS queue for job TenantAware HOT 12
- randomly receive Invalid catalog name: 1046 No database selected (Connection: mysql, SQL: insert into failed_jobs (uuid, connection, queue, payload, exception, failed_at) on queue sqs HOT 5
- Tenant Aware Queue Fails No Database Selected when running from supervisor in a multi tenant environment using AWS SQS FIFO HOT 2
- Update documentation at https://spatie.be to `v3` HOT 3
- in_array(): Argument #2 ($haystack) must be of type array, null given {"exception":"[object] (TypeError(code: 0): in_array(): Argument #2 ($haystack) must be of type array, null given at /spatie/laravel-multitenancy/src/Actions/MakeQueueTenantAwareAction.php:79) HOT 1
- Cache issue with spatie/laravel-permission in TenantAware Command HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-multitenancy.