OauthRepository.php 631 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: sdf_sky
  5. * Date: 2018/7/4
  6. * Time: 下午9:59
  7. */
  8. namespace App\Repositories;
  9. use App\Models\UserOauth;
  10. class OauthRepository
  11. {
  12. protected $userOauth;
  13. public function __construct(UserOauth $userOauth)
  14. {
  15. $this->userOauth = $userOauth;
  16. }
  17. /**
  18. * 绑定用户
  19. * @param $id
  20. * @param $userId 用户ID
  21. */
  22. public function bind($id, $userId)
  23. {
  24. $userOauth = $this->userOauth->find($id);
  25. if(!$userOauth){
  26. return false;
  27. }
  28. $userOauth->user_id = $userId;
  29. return $userOauth->save();
  30. }
  31. }