Skip to content

Commit

Permalink
Upgrade composer and npm
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisdelicata committed Jul 20, 2024
1 parent 098eac0 commit faa070f
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasDefaultTenant;
use Filament\Models\Contracts\HasTenants;
use Filament\Panel;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use JoelButcher\Socialstream\HasConnectedAccounts;
Expand All @@ -14,7 +21,7 @@
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
class User extends Authenticatable implements HasDefaultTenant, HasTenants, FilamentUser
{
use HasApiTokens;
use HasConnectedAccounts;
Expand All @@ -28,14 +35,6 @@ class User extends Authenticatable
use TwoFactorAuthenticatable;
use HasTeams;

/**
* Get the teams the user belongs to.
*/
public function teams()
{
return $this->belongsToMany(Team::class, 'team_user')->withTimestamps();
}

/**
* The attributes that are mass assignable.
*
Expand Down Expand Up @@ -91,10 +90,37 @@ public function profilePhotoUrl(): Attribute
}

/**
* Get the teams the user owns.
* @return array<Model> | Collection
*/
public function ownedTeams()
public function getTenants(Panel $panel): array|Collection
{
return $this->ownedTeams;
}

public function canAccessTenant(Model $tenant): bool
{
return true; //$this->ownedTeams->contains($tenant);
}

public function canAccessPanel(Panel $panel): bool
{
// return $this->hasVerifiedEmail();
return true;
}

public function canAccessFilament(): bool
{
// return $this->hasVerifiedEmail();
return true;
}

public function getDefaultTenant(Panel $panel): ?Model
{
return $this->latestTeam;
}

public function latestTeam(): BelongsTo
{
return $this->hasMany(Team::class);
return $this->belongsTo(Team::class, 'current_team_id');
}
}

0 comments on commit faa070f

Please sign in to comment.