DreamInfoModel.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. 'status'
  39. ];
  40. protected $hidden = ['deleted_at'];
  41. public function user()
  42. {
  43. return $this->hasOne('App\Models\UserInfoModel','id','user_id');
  44. }
  45. public function imgs()
  46. {
  47. return $this->hasMany('App\Models\DreamImages','dream_id');
  48. }
  49. public function img()
  50. {
  51. return $this->hasOne('App\Models\DreamImages','dream_id','id');
  52. }
  53. // 系统消息
  54. public function systemInfo()
  55. {
  56. return $this->hasMany('App\Models\SystemInfoModel','other_id','id');
  57. }
  58. public function interactions()
  59. {
  60. return $this->hasMany('App\Models\InteractionInfo','dream_id');
  61. }
  62. public function allInteraction()
  63. {
  64. return $this->hasManyThrough('App\Models\CommentInfoModel', 'App\Models\InteractionInfo','dream_id','interaction_id');
  65. }
  66. }