ice framework documentation ice doc v1.11.0
  1. namespace Ice\Auth\Driver\Model\Users;
  2.  
  3. use Ice\Mvc\Model;
  4.  
  5. /**
  6. * Model user's social auth.
  7. *
  8. * @package Ice/Auth
  9. * @category Model
  10. * @author Ice Team
  11. * @copyright (c) 2014-2025 Ice Team
  12. * @license http://iceframework.org/license
  13. */
  14. class Social extends Model
  15. {
  16. protected from = "user_social";
  17.  
  18. /**
  19. * User class name.
  20. */
  21. protected userClass = "Ice\\Auth\\Driver\\Model\\Users";
  22.  
  23. /**
  24. * Initialize relations.
  25. *
  26. * @return void
  27. */
  28. public function initialize()
  29. {
  30. var auth;
  31.  
  32. let auth = this->getDi()->get("auth");
  33.  
  34. this->hasOne("user_id", auth->getOption("users", this->userClass), this->getIdKey(), [
  35. "alias": "User"
  36. ]);
  37. }
  38.  
  39. /**
  40. * Set PRIMARY key.
  41. *
  42. * @return void
  43. */
  44. public function onConstruct()
  45. {
  46. this->setPrimary(["social_id", "type"]);
  47. }
  48. }