You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
803 B

  1. <?php
  2. namespace App\Service;
  3. use App\Model\UserRelationBind;
  4. class CommunityService implements CommunityServiceInterface
  5. {
  6. public function bind($data)
  7. {
  8. if ($res = $this->isBinded($data['bind_type'], $data['source_id'], $data['user_id'])) {
  9. return $res;
  10. }
  11. return UserRelationBind::query()->updateOrCreate(
  12. ['bind_type' => $data['bind_type'], 'source_id' => $data['source_id'], 'user_id' => $data['user_id']],
  13. ['json_data' => $data['json_data']]
  14. );
  15. }
  16. public function isBinded($bind_type, $source_id, $user_id)
  17. {
  18. return UserRelationBind::query()
  19. ->select('id')
  20. ->where(['bind_type' => $bind_type, 'source_id' => $source_id, 'user_id' => $user_id])
  21. ->first();
  22. }
  23. }