From b4be2d68a04d5d5858a364d89e833c190068eccd Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:11:25 +0000 Subject: [PATCH] Add teams and owned teams to User model --- app/Models/User.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Models/User.php b/app/Models/User.php index ef4c8825..c97f5622 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -23,6 +23,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. @@ -77,4 +87,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); + } }