Comments (4)
Please take a look at how Eloquent works under the hood. This has nothing to do with tenancy.
$user->tenants()->delete()
doesn't delete databases because it also doesn't trigger events. Laravel doesn't fetch each tenant to delete it individually here, it instead tells the SQL server to bulk delete tenants that match certain filters.
To delete a user's tenants with databases, you'd need to first fetch the model instances before calling delete()
on them individually.
from tenancy.
SQL servers can't run PHP. If you use ON DELETE CASCADE
, it will be the SQL server deleting the tenant record, not Laravel. Therefore none of Laravel's events will be fired.
I'd suggest using Laravel's events to delete the tenant record instead of CASCADE
.
from tenancy.
The issue persists even without ON DELETE CASCADE.
I've called the following:
$user->tenants()->delete();
$user->delete();
The tenant gets deleted, along with associated domains. But the tenant DB remains intact.
from tenancy.
Thanks @stancl
This solved the issue. Apologies for making assumptions regarding delete events getting triggered on collection.
from tenancy.
Related Issues (20)
- Undefined constant RedisCluster::OPT_PREFIX HOT 5
- With laravel breeze and react ,Inertia.js not working after installing the package HOT 1
- Wrong domain url when on queue HOT 2
- Jestream Laravel Tenacy HOT 5
- InitializeTenancyByPath with livewire within tenant context throws exception HOT 8
- Make runForMultiple yield the callbacks return HOT 5
- Sugestion new Middleware
- Pass tenant to handle when using TenantAwareCommand trait HOT 2
- Route helper in job doesn't use tenant context domain HOT 5
- Tenancy is not working for Livewire HOT 4
- Nested sub domain HOT 3
- Could Not Switch tenants when using Aritsan command HOT 1
- 3.8.3 ViteBundler incompatibility with Laravel 9 HOT 3
- laravel 10 support HOT 1
- LOG.warning tenantIdColumn is deprecated HOT 1
- PostgreSQL Tenant Database Not Automatically Created During Tenant Creation
- Call to a member function getTenantKey() on null HOT 2
- Using RedisTenancyBoostrapper causes problems with queue worker
- Issue with Invalidating Tenant Cache when Redis Data Separation is Enabled
- Create Tenant will trigger Tenancy bootstrappers HOT 1
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 tenancy.