diff --git a/app/Models/User.php b/app/Models/User.php index efdf513b..6b1c610d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -1,7 +1,120 @@ + + */ + protected $fillable = [ + 'name', + 'email', + 'password', + ]; + + /** + * The attributes that should be hidden for arrays. + * + * @var array + */ + protected $hidden = [ + 'password', + 'remember_token', + 'two_factor_recovery_codes', + 'two_factor_secret', + ]; + + /** + * The accessors to append to the model's array form. + * + * @var array + */ + protected $appends = [ + 'profile_photo_url', + ]; + + /** + * Get the attributes that should be cast. + * + * @return array + */ + protected function casts(): array + { + return [ + 'email_verified_at' => 'datetime', + ]; + } + + /** + * Get the URL to the user's profile photo. + */ + public function profilePhotoUrl(): Attribute + { + return filter_var($this->profile_photo_path, FILTER_VALIDATE_URL) + ? Attribute::get(fn () => $this->profile_photo_path) + : $this->getPhotoUrl(); + } + + /** + * @return array | Collection + */ + 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; diff --git a/database/seeders/PermissionsSeeder.php b/database/seeders/PermissionsSeeder.php index 213b7e45..997d9611 100644 --- a/database/seeders/PermissionsSeeder.php +++ b/database/seeders/PermissionsSeeder.php @@ -4,6 +4,7 @@ use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Artisan; +use App\Models\User; class PermissionsSeeder extends Seeder {