| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | trait HasLike |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Like has one relationship with the model. |
||
| 20 | * |
||
| 21 | * @return MorphOne |
||
| 22 | */ |
||
| 23 | public function likeOne(): MorphOne |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Like has many relationship with the model. |
||
| 30 | * |
||
| 31 | * @return MorphMany |
||
| 32 | */ |
||
| 33 | public function likes(): MorphMany |
||
| 34 | { |
||
| 35 | return $this->morphMany(Like::class, 'model'); |
||
| 36 | } |
||
| 37 | |||
| 38 | |||
| 39 | /** |
||
| 40 | * The scope locale for select likes relationship. |
||
| 41 | * |
||
| 42 | * @return MorphMany |
||
| 43 | */ |
||
| 44 | public function likesTo(): MorphMany |
||
| 45 | { |
||
| 46 | return $this->likes()->where('type', LikeTypeEnum::LIKE); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * The scope locale for select dislikes relationship. |
||
| 51 | * |
||
| 52 | * @return MorphMany |
||
| 53 | */ |
||
| 54 | public function dislikesTo(): MorphMany |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * The scope locale for select loves relationship. |
||
| 61 | * |
||
| 62 | * @return MorphMany |
||
| 63 | */ |
||
| 64 | public function lovesTo(): MorphMany |
||
| 67 | } |
||
| 68 | } |
||
| 69 |