TopicModel.php 809 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * 话题模型.
  4. *
  5. * @author jim <jim458734573@gmail.com>
  6. * @date 2020-01-29 10:08:58
  7. */
  8. declare(strict_types=1);
  9. namespace App\Model;
  10. use Hyperf\ModelCache\Cacheable;
  11. use Hyperf\ModelCache\CacheableInterface;
  12. class TopicModel extends BaseModel implements CacheableInterface
  13. {
  14. use Cacheable;
  15. /**
  16. * 表名.
  17. *
  18. * @var string
  19. */
  20. protected $table = 'topic';
  21. /**
  22. * 分类.
  23. * @return \Hyperf\Database\Model\Relations\HasOne
  24. */
  25. public function category()
  26. {
  27. return $this->hasOne(TopicCategoryModel::class, 'id', 'category_id');
  28. }
  29. /**
  30. * 用户.
  31. * @return \Hyperf\Database\Model\Relations\HasOne
  32. */
  33. public function user()
  34. {
  35. return $this->hasOne(UserModel::class, 'code', 'user_id');
  36. }
  37. }