DreamInfoModel.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. /**
  5. * @description dfghfdhfgfghfg
  6. * @author system;
  7. * @version 1.0
  8. * @date 2017-06-01 05:20:51
  9. *
  10. */
  11. class DreamInfoModel extends BaseModel
  12. {
  13. /**
  14. * 数据表名
  15. *
  16. * @var string
  17. *
  18. */
  19. protected $table = 'dream_info';
  20. /**
  21. 主键
  22. */
  23. protected $primaryKey = 'id';
  24. //分页
  25. protected $perPage = PAGE_NUMS;
  26. /**
  27. * 可以被集体附值的表的字段
  28. *
  29. * @var string
  30. */
  31. protected $fillable = [
  32. 'name',
  33. 'about',
  34. 'coin',
  35. 'time',
  36. 'get_coin',
  37. 'mark',
  38. 'parameter',
  39. 'code',
  40. 'status'
  41. ];
  42. protected $hidden = ['deleted_at'];
  43. public function user()
  44. {
  45. return $this->hasOne('App\Models\UserInfoModel','id','user_id');
  46. }
  47. public function imgs()
  48. {
  49. return $this->hasMany('App\Models\DreamImages','dream_id');
  50. }
  51. public function img()
  52. {
  53. return $this->hasOne('App\Models\DreamImages','dream_id','id');
  54. }
  55. // 系统消息
  56. public function systemInfo()
  57. {
  58. return $this->hasMany('App\Models\SystemInfoModel','other_id','id');
  59. }
  60. public function interactions()
  61. {
  62. return $this->hasMany('App\Models\InteractionInfo','dream_id');
  63. }
  64. public function allInteraction()
  65. {
  66. return $this->hasManyThrough('App\Models\CommentInfoModel', 'App\Models\InteractionInfo','dream_id','interaction_id');
  67. }
  68. }