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-webplusm2mo 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äger2mo ago
Thanks, I used global scope to ensure that the filtering is applied consistently across all queries for the Project model
tuto1902
tuto19022mo 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
tuto19022mo 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äger2mo ago
Thank you, I'll look into it , appreciate it