| @@ 366-376 (lines=11) @@ | ||
| 363 | * @param $topic_id |
|
| 364 | * @param $user_id |
|
| 365 | */ |
|
| 366 | public function favorite($topic_id, $user_id) |
|
| 367 | { |
|
| 368 | $topic = new Topic(); |
|
| 369 | $topic->id = $topic_id; |
|
| 370 | ||
| 371 | if ($topic->favoriteBy()->wherePivot('user_id', $user_id)->exists()) { |
|
| 372 | return; |
|
| 373 | } |
|
| 374 | ||
| 375 | $topic->favoriteBy()->attach($user_id); |
|
| 376 | } |
|
| 377 | ||
| 378 | /** |
|
| 379 | * 取消收藏帖子. |
|
| @@ 397-407 (lines=11) @@ | ||
| 394 | * @param $topic_id |
|
| 395 | * @param $user_id |
|
| 396 | */ |
|
| 397 | public function attention($topic_id, $user_id) |
|
| 398 | { |
|
| 399 | $topic = new Topic(); |
|
| 400 | $topic->id = $topic_id; |
|
| 401 | ||
| 402 | if ($topic->attentionBy()->wherePivot('user_id', $user_id)->exists()) { |
|
| 403 | return; |
|
| 404 | } |
|
| 405 | ||
| 406 | $topic->attentionBy()->attach($user_id); |
|
| 407 | } |
|
| 408 | ||
| 409 | /** |
|
| 410 | * 取消关注帖子. |
|