public function isParticipant(Tournament $tournament) {
foreach ($tournament->participants as $participant) {
- if ($participant->user->id == $this->id) {
+ if ($participant->user_id == $this->id) {
return true;
}
}
return false;
}
+ public function isRunner(Tournament $tournament) {
+ foreach ($tournament->participants as $participant) {
+ if ($participant->user_id == $this->id) {
+ return in_array('runner', $participant->roles);
+ }
+ }
+ return false;
+ }
+
+ public function isTournamentAdmin(Tournament $tournament) {
+ foreach ($tournament->participants as $participant) {
+ if ($participant->user_id == $this->id) {
+ return in_array('admin', $participant->roles);
+ }
+ }
+ return false;
+ }
+
+ public function participation() {
+ return $this->hasMany(Participant::class);
+ }
+
/**
* The attributes that are mass assignable.
*