Skip to content

Commit

Permalink
Merge pull request #71 from liberusoftware/sweep/run_php_artisan_dbse…
Browse files Browse the repository at this point in the history
…ed_info_seeding

Sweep: Add `HasTeams` trait and `ownedTeams()` method to `User` model
  • Loading branch information
curtisdelicata authored Jun 16, 2024
2 parents 0b37116 + b4be2d6 commit a46ac1c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}

0 comments on commit a46ac1c

Please sign in to comment.