© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo ago•
1 reply
kcniverba-mis

Tenancy Model Scoping Best Practices

With multi-tenancy implemented, what's the best practice to scope Eloquent models to a Tenant

Is this the correct approach? I don't see any documentation on creating models/migrations with multi-tenancy and any opinionated advice on this would be great.

Schema::create('invitations', function (Blueprint $table) {
            $table->foreignIdFor(Organization::class)
                ->constrained()
                ->cascadeOnDelete();

            $table->string('email')->index();
 
            $table->foreignId('invited_by_id')
                ->constrained('users')
                ->cascadeOnDelete();

...
        });
Schema::create('invitations', function (Blueprint $table) {
            $table->foreignIdFor(Organization::class)
                ->constrained()
                ->cascadeOnDelete();

            $table->string('email')->index();
 
            $table->foreignId('invited_by_id')
                ->constrained('users')
                ->cascadeOnDelete();

...
        });


class Invitation extends Model
{
    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class);
    }

    public function inviter()
    {
        return $this->belongsTo(User::class, 'invited_by_id');
    }
class Invitation extends Model
{
    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class);
    }

    public function inviter()
    {
        return $this->belongsTo(User::class, 'invited_by_id');
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Disable Filament Tenancy Scoping for a Model
FilamentFFilament / ❓┊help
5mo ago
Resource Scoping Best Practice
FilamentFFilament / ❓┊help
2y ago
Icons best practices
FilamentFFilament / ❓┊help
3y ago
Tenancy with other packages Model
FilamentFFilament / ❓┊help
13mo ago