77 lines
2.3 KiB
PHP
77 lines
2.3 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | 麦沃德科技赋能开发者,助力商协会发展
|
||
// +----------------------------------------------------------------------
|
||
// | Copyright (c) 2017~2024 www.wdsxh.cn All rights reserved.
|
||
// +----------------------------------------------------------------------
|
||
// | 沃德商协会系统并不是自由软件,不加密,并不代表开源,未经许可不可自由转售和商用
|
||
// +----------------------------------------------------------------------
|
||
// | Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
|
||
// +----------------------------------------------------------------------
|
||
/**
|
||
* Class Article
|
||
* Desc 文章管理
|
||
* Create on 2024/3/12 10:10
|
||
* Create by @小趴菜
|
||
*/
|
||
|
||
namespace app\api\model\wdsxh\article;
|
||
|
||
use think\Model;
|
||
|
||
class Article extends Model
|
||
{
|
||
// 表名
|
||
protected $name = 'wdsxh_article';
|
||
|
||
// 自动写入时间戳字段
|
||
protected $autoWriteTimestamp = true;
|
||
|
||
// 定义时间戳字段名
|
||
protected $createTime = true;
|
||
protected $updateTime = false;
|
||
protected $deleteTime = false;
|
||
|
||
protected function getCreatetimeAttr($value)
|
||
{
|
||
$new_date = date("Y-m-d H:i", $value);
|
||
return $new_date;
|
||
}
|
||
|
||
protected function getImageAttr($value)
|
||
{
|
||
return wdsxh_full_url($value);
|
||
}
|
||
|
||
protected function getFilesAttr($value, $data)
|
||
{
|
||
$return_data = [];
|
||
if (empty($value)) {
|
||
return $return_data;
|
||
} else {
|
||
$filesdataArray = json_decode($data['filesdata'], true);
|
||
$array = explode(',',$value);
|
||
foreach ($array as $k=>$v) {
|
||
// 获取文件扩展名
|
||
$path_parts = pathinfo($v);
|
||
$extension = isset($path_parts['extension']) ? '.' . $path_parts['extension'] : '';
|
||
|
||
// 拼接文件名和扩展名
|
||
$fullName = $filesdataArray[$k]['name'] . $extension;
|
||
|
||
$return_data[$k] = array(
|
||
'name'=>$fullName,
|
||
'file'=>wdsxh_full_url($v),
|
||
);
|
||
}
|
||
return $return_data;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|