-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.php
More file actions
executable file
·41 lines (33 loc) · 840 Bytes
/
Team.php
File metadata and controls
executable file
·41 lines (33 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App;
class Team extends Model
{
public function invites()
{
return $this->hasMany(TeamInvite::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function servers()
{
return $this->belongsToMany(Server::class);
}
public function hasMember(User $user)
{
if ((int) $this->user_id === (int) $user->id) {
return true;
}
return (bool) $this->invites()->where('status', 'accepted')
->where('user_id', $user->id)
->first();
}
public function hasInvite(User $user) {
if ((int) $this->user_id === (int) $user->id) {
return false;
}
return (bool) $this->invites()->where('user_id', $user->id)
->first();
}
}