Skip to content

Commit a80bc69

Browse files
committed
Added missing model
1 parent eea073f commit a80bc69

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Concerns\HasUuids;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
8+
9+
class SecretSantaParticipant extends Model
10+
{
11+
use SoftDeletes, HasUuids;
12+
13+
protected $fillable = [
14+
'address',
15+
'about',
16+
'tracking_number',
17+
'telegram',
18+
'phone',
19+
];
20+
21+
/**
22+
* @var string[]
23+
*/
24+
protected $with = [
25+
'receiver'
26+
];
27+
28+
// Связь с пользователем
29+
public function user()
30+
{
31+
return $this->belongsTo(User::class);
32+
}
33+
34+
// Связь с получателем
35+
public function receiver()
36+
{
37+
return $this
38+
->belongsTo(SecretSantaParticipant::class, 'receiver_id', 'user_id')
39+
->without('receiver');
40+
}
41+
42+
/**
43+
* @return bool
44+
*/
45+
public function hasReceiver(): bool
46+
{
47+
return $this->receiver_id !== null;
48+
}
49+
}

0 commit comments

Comments
 (0)