BaseModel.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }