BaseModel.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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;
  15. use app\common\service\FileService;
  16. use think\Model;
  17. /**
  18. * 基础模型
  19. * Class BaseModel
  20. * @package app\common\model
  21. */
  22. class BaseModel extends Model
  23. {
  24. /**
  25. * @notes 公共处理图片,补全路径
  26. * @param $value
  27. * @return string
  28. * @author 张无忌
  29. * @date 2021/9/10 11:02
  30. */
  31. public function getImageAttr($value)
  32. {
  33. return trim($value) ? FileService::getFileUrl($value) : '';
  34. }
  35. /**
  36. * @notes 公共图片处理,去除图片域名
  37. * @param $value
  38. * @return mixed|string
  39. * @author 张无忌
  40. * @date 2021/9/10 11:04
  41. */
  42. public function setImageAttr($value)
  43. {
  44. return trim($value) ? FileService::setFileUrl($value) : '';
  45. }
  46. public function getImagesAttr($value)
  47. {
  48. if(trim($value)){
  49. $imgArr = explode(',',$value);
  50. foreach ($imgArr as &$v){
  51. $v = FileService::getFileUrl($v);
  52. }
  53. return implode(',',$imgArr);
  54. }else{
  55. return '';
  56. }
  57. }
  58. public function setImagesAttr($value)
  59. {
  60. if(trim($value)){
  61. $imgArr = explode(',',$value);
  62. foreach ($imgArr as &$v){
  63. $v = FileService::setFileUrl($v);
  64. }
  65. return implode(',',$imgArr);
  66. }else{
  67. return '';
  68. }
  69. }
  70. /**
  71. * @notes 公共处理图片,补全路径
  72. * @param $value
  73. * @return string
  74. * @author 张无忌
  75. * @date 2021/9/10 11:02
  76. */
  77. public function getLicenseImageAttr($value)
  78. {
  79. return trim($value) ? FileService::getFileUrl($value) : '';
  80. }
  81. /**
  82. * @notes 公共图片处理,去除图片域名
  83. * @param $value
  84. * @return mixed|string
  85. * @author 张无忌
  86. * @date 2021/9/10 11:04
  87. */
  88. public function setLicenseImageAttr($value)
  89. {
  90. return trim($value) ? FileService::setFileUrl($value) : '';
  91. }
  92. public function getLeaseContractImageAttr($value)
  93. {
  94. if(trim($value)){
  95. $imgArr = explode(',',$value);
  96. foreach ($imgArr as &$v){
  97. $v = FileService::getFileUrl($v);
  98. }
  99. return implode(',',$imgArr);
  100. }else{
  101. return '';
  102. }
  103. }
  104. public function setLeaseContractImageAttr($value)
  105. {
  106. if(trim($value)){
  107. $imgArr = explode(',',$value);
  108. foreach ($imgArr as &$v){
  109. $v = FileService::setFileUrl($v);
  110. }
  111. return implode(',',$imgArr);
  112. }else{
  113. return '';
  114. }
  115. }
  116. }