FilamentF
Filament13mo ago
3 replies
DevShaded

Tenancy with entire domain returns 404

Hello, I am trying to setup tenancy with entire domain configuration. When I try to register a new team, and try to access the panel trough the domain club1.test (that is the team domain i registered with) I get a 404. Its my first time trying this so i am not sure how this works..

Here is my configuration:

User.php
// User.php

class User extends Authenticatable implements FilamentUser, HasTenants
{
    /** @use HasFactory<\Database\Factories\UserFactory> */
    use HasFactory, Notifiable;

    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    public function getTenants(Panel $panel): array|Collection
    {
        return $this->teams;
    }

    public function teams(): BelongsToMany
    {
        return $this->belongsToMany(Team::class);
    }

    public function canAccessTenant(Model $tenant): bool
    {
        return $this->teams()->whereKey($tenant)->exists();
    }

    public function canAccessPanel(Panel $panel): bool
    {
        return true;
    }
}


 // Team.php
    protected $fillable = [
        'name',
        'domain',
    ];

    public function players(): HasMany
    {
        return $this->hasMany(Players::class, 'team_id');
    }

    public function members(): BelongsToMany
    {
        return $this->belongsToMany(User::class);
    }


AdminPanelProvider.php

            ->tenant(Team::class, slugAttribute: 'domain')
            ->tenantDomain('{tenant:domain}')
            ->tenantRegistration(RegisterTeam::class)
            ->tenantProfile(EditTeamProfile::class);
image.png
Solution
I fixed the problem, when I stored the domain i stored it as an url like this http://club1.test instead of just the domain like this club.test 🙂
Was this page helpful?