CommentModel.php 710 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * 评论模型.
  4. *
  5. * @author jim <jim458734573@gmail.com>
  6. * @date 2020-01-28 20:16:26
  7. */
  8. declare(strict_types=1);
  9. namespace App\Model;
  10. use Hyperf\ModelCache\Cacheable;
  11. use Hyperf\ModelCache\CacheableInterface;
  12. class CommentModel extends BaseModel implements CacheableInterface
  13. {
  14. use Cacheable;
  15. /**
  16. * 表名.
  17. *
  18. * @var string
  19. */
  20. protected $table = 'comment';
  21. protected $casts = [
  22. 'content' => 'string',
  23. 'quote' => 'string',
  24. ];
  25. /**
  26. * 关联一个用户.
  27. * @return \Hyperf\Database\Model\Relations\HasOne
  28. */
  29. public function user()
  30. {
  31. return $this->hasOne(UserModel::class, 'code', 'user_id');
  32. }
  33. }