Skip to content

Commit

Permalink
Show secret code on santa
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Dec 20, 2024
1 parent 40393c6 commit 548acc4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/Models/SecretSantaParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SecretSantaParticipant extends Model
*/
protected $with = [
'receiver',
'santa'
];

// Связь с пользователем
Expand All @@ -36,7 +37,15 @@ public function receiver()
{
return $this
->belongsTo(SecretSantaParticipant::class, 'receiver_id', 'user_id')
->without('receiver');
->without('receiver', 'santa');
}

// Связь с Сантой (кто отправляет мне подарок)
public function santa()
{
return $this
->hasOne(SecretSantaParticipant::class, 'receiver_id', 'user_id')
->without('receiver', 'santa');
}

/**
Expand All @@ -46,4 +55,14 @@ public function hasReceiver(): bool
{
return $this->receiver_id !== null;
}

/**
* Проверяет, есть ли у пользователя Санта
*
* @return bool
*/
public function hasSanta(): bool
{
return $this->santa !== null;
}
}

0 comments on commit 548acc4

Please sign in to comment.