| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- // +----------------------------------------------------------------------
- // | likeadmin快速开发前后端分离管理后台(PHP版)
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | 开源版本可自由商用,可去除界面版权logo
- // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
- // | github下载:https://github.com/likeshop-github/likeadmin
- // | 访问官网:https://www.likeadmin.cn
- // | likeadmin团队 版权所有 拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeadminTeam
- // +----------------------------------------------------------------------
- namespace app\common\model\supply_demand;
- use app\common\model\agricultural_machinery\ServiceCategory;
- use app\common\model\BaseModel;
- use app\common\model\asset\AssetArea;
- use app\common\model\recharge\RechargeOrder;
- use app\common\service\FileService;
- use app\common\model\User\User;
- use think\model\concern\SoftDelete;
- /**
- * 供需分类模型
- * Class ArticleCate
- * @package app\common\model\article;
- */
- class SupplyDemandCate extends BaseModel
- {
- use SoftDelete;
- protected $deleteTime = 'delete_time';
- /**
- * @notes 关联用户
- * @return \think\model\relation\HasMany
- * @author 段誉
- * @date 2022/10/19 16:59
- */
- public function user()
- {
- return $this->hasOne(User::class, 'id', 'user_id')->field('id,nickname,avatar,account');
- }
- /**
- * @notes 状态描述
- * @param $value
- * @param $data 状态 0 新增待发布 1审核中 2 审核成功 3审核失败
- * @return string
- * @author 段誉
- * @date 2022/9/15 11:25
- */
- public function getStatusDescAttr($value,$data){
- $status = $data['status'];
- $desc = [
- 0 => '隐藏',
- 1 => '显示',
- ];
- return $desc[$status] ?? '';
- }
- public function getTypeDescAttr($value,$data){
- $type = $data['type'];
- $desc = [
- 1 => '供应',
- 2 => '需求',
- ];
- return $desc[$type] ?? '';
- }
- /**
- * @notes 设置图片域名
- * @param $value
- * @param $data
- * @return array|string|string[]|null
- * @author 段誉
- * @date 2022/9/28 10:17
- */
- public function getContentAttr($value, $data)
- {
- return get_file_domain($value);
- }
- /**
- * @notes 清除图片域名
- * @param $value
- * @param $data
- * @return array|string|string[]
- * @author 段誉
- * @date 2022/9/28 10:17
- */
- public function setContentAttr($value, $data)
- {
- return clear_file_domain($value);
- }
- /**
- * @notes 清除图片域名
- * @param $value
- * @param $data
- * @return array|string|string[]
- * @author 段誉
- * @date 2022/9/28 10:17
- */
- public function setImagesAttr($value)
- {
- $imagesArr = explode(',',$value);
- $imagesStr = '';
- foreach($imagesArr as $k=>$v){
- if($k==0){
- $imagesStr = clear_file_domain($v);
- }else{
- $imagesStr .=','. clear_file_domain($v);
- }
- }
- return $imagesStr;
- }
- /**
- * @notes 加图片域名
- * @param $value
- * @param $data
- * @return array|string|string[]
- * @author 段誉
- * @date 2022/9/28 10:17
- */
- public function getImagesAttr($value,$data)
- {
- $imagesArr = explode(',',$data['images']);
- $imagesStr = '';
- foreach($imagesArr as $k=>$v){
- if($k==0){
- $imagesStr = FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
- }else{
- $imagesStr .=','. FileService::getFileUrl(trim($v, '/')); //get_file_domain($v);
- }
- }
- return $imagesStr;
- }
- }
|