Delete Tenant
I might know the answer already (No) but I might as well ask. Just to be sure. Is there a way, or is it even allowed to delete Tenants?
Solution:Jump to solution
If you are asking about how to go about this, look at this package. Its a feature of it.
https://github.com/andrewdwallo/filament-companies...
GitHub
GitHub - andrewdwallo/filament-companies
Contribute to andrewdwallo/filament-companies development by creating an account on GitHub.
24 Replies
Good question
What wouldn’t it be? Are you seeing any issues trying to do it.
Well, let me explain: Is it allowed to have a ClinicResource so, lets say, an admin user can Add/Remove clinics
I think my mind got stuck when I started thinking about the model relationships
You probably just have to make sure the tenant_id is connected to all tables and use something like this:
Right, but I can't do something like
Since the Company model would need a
company
relationship. Plus, (once created) that company would only belong to the Company you are currently working on. See? complete brain cramp 😵💫Not if you have multiple companies
This is why path based tenancy sucks. Subdomains helps to keep it all in mental context. 😅
Keep it so that one company a user has can't be deleted
Why shouldn’t the company be able to be deleted and then cascade all its users?
I mean yeah if a user belongs to the company being deleted then those users would be deleted as well...
Thats why you need to make sure the user really wants to delete the company before they do it
The question arises from this: I have a
UserResource
that an Admin can use to create new users. Inside, I have a multiple Select
input tied to the companies
relationship on that model. I added the createOptionForm, so I can create a new company on the fly. But now I'm thinking, what if the admin creates a company by mistake. Hence the need of a CompanyResourceI mean yeah I would add the feature to be able to delete companies/tenants
I'm going to
I think its needed
but riddle me this. When I create the Company resource I'm faced with this error when trying to access it:
With every other resource, the company relationship it's a belongsToMany(Company::class).
Do I create a pivot table called company_company and have the Company model belong to itself?
Solution
If you are asking about how to go about this, look at this package. Its a feature of it.
https://github.com/andrewdwallo/filament-companies
GitHub
GitHub - andrewdwallo/filament-companies
Contribute to andrewdwallo/filament-companies development by creating an account on GitHub.
The models should be similar to what is used in Filament v3 tenancy
Interesting 🤔 I'll give it a try. Thanks for the help!
Its similar to the way Jetstream works if you have ever used that.
Never have I ever. But I like having to learn something new 👍
Yep learning tenancy architecture takes a while to learn fluently. Good luck!
@tuto1902 You can also download and try it out yourself with this package. https://github.com/andrewdwallo/erpsaas
This may help you understand everything more..
GitHub
GitHub - andrewdwallo/erpsaas
Contribute to andrewdwallo/erpsaas development by creating an account on GitHub.
Awesome! I'll look into it
Let me know how it goes. Feel free to message me if you have any questions!
I'm probably late to this post but something like this is what the OP needs