SupplyDemandInfo.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\model\supply_demand;
  15. use app\common\model\agricultural_machinery\ServiceCategory;
  16. use app\common\model\BaseModel;
  17. use app\common\model\asset\AssetArea;
  18. use app\common\model\recharge\RechargeOrder;
  19. use app\common\service\FileService;
  20. use app\common\model\User\User;
  21. use think\model\concern\SoftDelete;
  22. /**
  23. * 服务管理模型
  24. * Class ArticleCate
  25. * @package app\common\model\article;
  26. */
  27. class SupplyDemandInfo extends BaseModel
  28. {
  29. use SoftDelete;
  30. protected $deleteTime = 'delete_time';
  31. /**
  32. * @notes 关联用户
  33. * @return \think\model\relation\HasMany
  34. * @author 段誉
  35. * @date 2022/10/19 16:59
  36. */
  37. public function user()
  38. {
  39. return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname,avatar');
  40. }
  41. /**
  42. * @notes 状态描述
  43. * @param $value
  44. * @param $data 状态 0 新增待发布 1审核中 2 审核成功 3审核失败
  45. * @return string
  46. * @author 段誉
  47. * @date 2022/9/15 11:25
  48. */
  49. public function getStatusDescAttr($value,$data){
  50. $type = $data['type'];
  51. $desc = [
  52. 0 => '新增待审核',
  53. 1 => '审核中',
  54. 2 => '审核成功',
  55. 3 => '审核失败',
  56. ];
  57. return $desc[$type] ?? '';
  58. }
  59. public function getTypeDescAttr($value,$data){
  60. $type = $data['type'];
  61. $desc = [
  62. 1 => '供应',
  63. 2 => '需求',
  64. ];
  65. return $desc[$type] ?? '';
  66. }
  67. /**
  68. * @notes 设置图片域名
  69. * @param $value
  70. * @param $data
  71. * @return array|string|string[]|null
  72. * @author 段誉
  73. * @date 2022/9/28 10:17
  74. */
  75. public function getContentAttr($value, $data)
  76. {
  77. return get_file_domain($value);
  78. }
  79. /**
  80. * @notes 清除图片域名
  81. * @param $value
  82. * @param $data
  83. * @return array|string|string[]
  84. * @author 段誉
  85. * @date 2022/9/28 10:17
  86. */
  87. public function setContentAttr($value, $data)
  88. {
  89. return clear_file_domain($value);
  90. }
  91. /**
  92. * @notes 清除图片域名
  93. * @param $value
  94. * @param $data
  95. * @return array|string|string[]
  96. * @author 段誉
  97. * @date 2022/9/28 10:17
  98. */
  99. public function setImagesAttr($value)
  100. {
  101. $imagesArr = explode(',',$value);
  102. $imagesStr = '';
  103. foreach($imagesArr as $k=>$v){
  104. if($k==0){
  105. $imagesStr = clear_file_domain($v);
  106. }else{
  107. $imagesStr .=','. clear_file_domain($v);
  108. }
  109. }
  110. return $imagesStr;
  111. }
  112. /**
  113. * @notes 加图片域名
  114. * @param $value
  115. * @param $data
  116. * @return array|string|string[]
  117. * @author 段誉
  118. * @date 2022/9/28 10:17
  119. */
  120. public function getImagesAttr($value,$data)
  121. {
  122. $imagesArr = explode(',',$data['images']);
  123. $imagesStr = '';
  124. foreach($imagesArr as $k=>$v){
  125. if($k==0){
  126. $imagesStr = FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
  127. }else{
  128. $imagesStr .=','. FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
  129. }
  130. }
  131. return $imagesStr;
  132. }
  133. }