SupplyDemandInfo.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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\model\supply_demand\SupplyDemandCate;
  20. use app\common\service\FileService;
  21. use app\common\model\user\User;
  22. use think\model\concern\SoftDelete;
  23. /**
  24. * 服务管理模型
  25. * Class ArticleCate
  26. * @package app\common\model\article;
  27. */
  28. class SupplyDemandInfo extends BaseModel
  29. {
  30. use SoftDelete;
  31. protected $deleteTime = 'delete_time';
  32. /**
  33. * @notes 关联用户
  34. * @return \think\model\relation\HasMany
  35. * @author 段誉
  36. * @date 2022/10/19 16:59
  37. */
  38. public function user()
  39. {
  40. return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname,avatar,account');
  41. }
  42. /**
  43. * @notes 关联分类
  44. * @return \think\model\relation\HasMany
  45. * @author 段誉
  46. * @date 2022/10/19 16:59
  47. */
  48. public function cateInfo()
  49. {
  50. return $this->hasOne(SupplyDemandCate::class, 'id', 'cate_id')->field('id,name');
  51. }
  52. /**
  53. * @notes 状态描述
  54. * @param $value
  55. * @param $data 状态 0 新增待发布 1审核中 2 审核成功 3审核失败
  56. * @return string
  57. * @author 段誉
  58. * @date 2022/9/15 11:25
  59. */
  60. public function getStatusDescAttr($value,$data){
  61. $status = $data['status'];
  62. $desc = [
  63. 0 => '新增待提交',
  64. 1 => '审核中',
  65. 2 => '审核成功',
  66. 3 => '审核失败',
  67. ];
  68. return $desc[$status] ?? '';
  69. }
  70. public function getTypeDescAttr($value,$data){
  71. $type = $data['type'];
  72. $desc = [
  73. 1 => '供应',
  74. 2 => '需求',
  75. ];
  76. return $desc[$type] ?? '';
  77. }
  78. /**
  79. * @notes 设置图片域名
  80. * @param $value
  81. * @param $data
  82. * @return array|string|string[]|null
  83. * @author 段誉
  84. * @date 2022/9/28 10:17
  85. */
  86. public function getContentAttr($value, $data)
  87. {
  88. return get_file_domain($value);
  89. }
  90. /**
  91. * @notes 清除图片域名
  92. * @param $value
  93. * @param $data
  94. * @return array|string|string[]
  95. * @author 段誉
  96. * @date 2022/9/28 10:17
  97. */
  98. public function setContentAttr($value, $data)
  99. {
  100. return clear_file_domain($value);
  101. }
  102. /**
  103. * @notes 清除图片域名
  104. * @param $value
  105. * @param $data
  106. * @return array|string|string[]
  107. * @author 段誉
  108. * @date 2022/9/28 10:17
  109. */
  110. public function setImagesAttr($value)
  111. {
  112. $imagesArr = explode(',',$value);
  113. $imagesStr = '';
  114. foreach($imagesArr as $k=>$v){
  115. if($k==0){
  116. $imagesStr = clear_file_domain($v);
  117. }else{
  118. $imagesStr .=','. clear_file_domain($v);
  119. }
  120. }
  121. return $imagesStr;
  122. }
  123. /**
  124. * @notes 加图片域名
  125. * @param $value
  126. * @param $data
  127. * @return array|string|string[]
  128. * @author 段誉
  129. * @date 2022/9/28 10:17
  130. */
  131. public function getImagesAttr($value,$data)
  132. {
  133. $imagesArr = explode(',',$data['images']);
  134. $imagesStr = '';
  135. foreach($imagesArr as $k=>$v){
  136. if($k==0){
  137. $imagesStr = FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
  138. }else{
  139. $imagesStr .=','. FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
  140. }
  141. }
  142. return $imagesStr;
  143. }
  144. }