This commit is contained in:
Joao Patricio
2023-03-30 20:24:43 +01:00
parent f05ab87c08
commit a852a15dab
6 changed files with 53 additions and 19 deletions

View File

@@ -51,17 +51,21 @@ class User extends Authenticatable
$model->uuid = (string) new Cuid2(7);
});
}
public function teams()
{
return $this->belongsToMany(Team::class);
}
public function currentTeam()
{
return $this->belongsTo(Team::class);
}
public function otherTeams()
{
$team_id = session('currentTeam')->id;
$team_id = data_get(session('currentTeam'), 'id');
return auth()->user()->teams->filter(function ($team) use ($team_id) {
return $team->id != $team_id;
});