user_customer.php 603 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Class UserCustomer
  4. *
  5. * @property int $user_id
  6. * @property int $customer_id
  7. */
  8. class UserCustomer extends Model {
  9. protected static $table = "user_customer";
  10. protected static $id_field = ["user_id", "customer_id"];
  11. protected static $fillable_fields = ["user_id", "customer_id"];
  12. // Object methods
  13. /**
  14. * @return User|null
  15. * @throws Exception
  16. */
  17. public function getUser(): ?User {
  18. return User::get($this->user_id);
  19. }
  20. /**
  21. * @return Customer|null
  22. * @throws Exception
  23. */
  24. public function getCustomer(): ?Customer {
  25. return Customer::get($this->customer_id);
  26. }
  27. }