File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments