Total Complexity | 3 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
20 | trait LoveScope |
||
21 | { |
||
22 | /** |
||
23 | * The scope locale for select love relationship. |
||
24 | * |
||
25 | * @return MorphOne |
||
26 | */ |
||
27 | public function loveTo(): MorphOne |
||
28 | { |
||
29 | return $this->likeOne()->where('type', InteractionTypeEnum::LOVE); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * The scope locale for select loves relationship. |
||
34 | * |
||
35 | * @return MorphMany |
||
36 | */ |
||
37 | public function lovesTo(): MorphMany |
||
38 | { |
||
39 | return $this->likes()->where('type', InteractionTypeEnum::LOVE); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Check if the model has been loved by the given user. |
||
44 | * |
||
45 | * @param int $userId |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function isLovedBy(int $userId): bool |
||
52 | } |
||
53 | } |
||
54 |