AlbumCommentsModel.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * @description 评论管理
  7. * @author system;
  8. * @version 1.0
  9. * @date 2018-05-14 10:49:40
  10. *
  11. */
  12. class AlbumCommentsModel extends BaseModel
  13. {
  14. use SoftDeletes;
  15. protected $dates = ['delete_at'];
  16. /**
  17. * 数据表名
  18. *
  19. * @var string
  20. *
  21. */
  22. protected $table = 'album_comments';
  23. /**
  24. * 主键
  25. */
  26. protected $primaryKey = 'id';
  27. //分页
  28. protected $perPage = PAGE_NUMS;
  29. /**
  30. * 可以被集体附值的表的字段
  31. *
  32. * @var string
  33. */
  34. protected $fillable = [
  35. 'store_id',
  36. 'user_id',
  37. 'comments_id',
  38. 'content',
  39. 'sys_reply',
  40. 'news_id',
  41. ];
  42. public function user()
  43. {
  44. return $this->belongsTo('App\Models\AlbumUserModel', 'user_id');
  45. }
  46. public function username(){
  47. return (new AlbumUserModel())->find($this->user_id)?(new AlbumUserModel())->find($this->user_id)->username:$this->user_id;
  48. }
  49. public function replys(){
  50. return $this->hasMany('App\Models\AlbumCommentsModel','comments_id','id');
  51. }
  52. }