Filter Filament Project Resources Based on Authenticated User's Team

I'm working on a Laravel application with a Filament admin panel. I need to filter the projects displayed in the admin panel so that only projects related to the authenticated user's team are shown. Here's a summary of my setup and what I've tried so far: Database Schema: User: belongs to a Team Team: has many Users and Projects Project: belongs to a Team Could someone guide me on the correct approach ? Thank you!
No description
5 Replies
Dan-webplusm
Dan-webplusm7mo ago
User -> Teams -> Projects : auth()->user()->teams->projects : I suppose it would be this , the list of projects in a select. May be you probably need tenants
karim_Jäger
karim_JägerOP7mo ago
Thanks, I used global scope to ensure that the filtering is applied consistently across all queries for the Project model
tuto1902
tuto19027mo ago
@karim_Jäger Here's a good read. This will guide you to implement multi-tenancy and keep projects scoped to the user's team https://filamentphp.com/docs/3.x/panels/tenancy#simple-one-to-many-tenancy
tuto1902
tuto19027mo ago
I would recommend sticking with Simple Tenancy (one-to-many). This is way simpler than using filament's Multi-Tenancy which doesn't seem to be neccesary given your database schema
karim_Jäger
karim_JägerOP7mo ago
Thank you, I'll look into it , appreciate it
Want results from more Discord servers?
Add your server