From 9fff62f53dbd401606e2ea481f9435e7e54aef76 Mon Sep 17 00:00:00 2001 From: Curtis Delicata Date: Sat, 29 Jun 2024 15:20:44 +0000 Subject: [PATCH] Configure Jetstream classes in providers and separate panels into Admin and App --- app/Models/User.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index 6e6d3567..be1a6360 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,6 +10,7 @@ use JoelButcher\Socialstream\SetsProfilePhotoFromUrl; use Laravel\Fortify\TwoFactorAuthenticatable; use Laravel\Jetstream\HasProfilePhoto; +use Laravel\Jetstream\HasTeams; use Laravel\Sanctum\HasApiTokens; use Spatie\Permission\Traits\HasRoles; @@ -25,6 +26,16 @@ class User extends Authenticatable use Notifiable; use SetsProfilePhotoFromUrl; use TwoFactorAuthenticatable; + use HasTeams; + + /** + * Get the teams the user belongs to. + */ + public function teams() + { + return $this->belongsToMany(Team::class, 'team_user')->withTimestamps(); + } + use Laravel\Jetstream\HasTeams; /** * The attributes that are mass assignable. @@ -79,4 +90,12 @@ public function profilePhotoUrl(): Attribute ? Attribute::get(fn () => $this->profile_photo_path) : $this->getPhotoUrl(); } + + /** + * Get the teams the user owns. + */ + public function ownedTeams() + { + return $this->hasMany(Team::class); + } }