Files
crm-server/app/model/Follow.php
T

65 lines
2.0 KiB
PHP
Raw Normal View History

2025-03-14 14:27:33 +08:00
<?php
namespace app\model;
2025-03-22 17:44:42 +08:00
use app\service\OssService;
2025-03-18 15:07:22 +08:00
use app\util\Util;
2025-03-14 14:27:33 +08:00
use config\constants\Constants;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Follow extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
2025-07-23 16:55:18 +08:00
protected $table = 'crm_follow';
2025-03-14 14:27:33 +08:00
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
//设置黑名单
protected $guarded = ['id','created_at','updated_at'];
// 指定日期字段存储格式为时间戳
protected $dateFormat = 'U';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $casts = [
2025-03-20 10:01:21 +08:00
'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'follow_time' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
// 'updated_at' => 'timestamp', // 指定序列化格式
// 'created_at' => 'timestamp', // 指定序列化格式
2025-03-14 14:27:33 +08:00
];
2025-03-19 17:54:44 +08:00
public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com')
2025-03-14 14:27:33 +08:00
{
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
2025-06-23 13:44:55 +08:00
$follow['firstFollowtime'] = $follow['follow_time'];
2025-06-23 14:06:39 +08:00
if (isset($follow['picture']) && !empty($follow['picture'])) {
2025-06-23 13:44:55 +08:00
$ossservice = new OssService();
$oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400);
$follow['oss_picture'] = $oss_picture;
}else {
$follow['oss_picture'] = '';
}
2025-07-23 16:55:18 +08:00
$follow['created_at'] = (!empty($follow['created_at']))?date('Y-m-d H:i:s',strtotime($follow['created_at'])+(3600*8)):'';
$follow['updated_at'] = (!empty($follow['updated_at']))?date('Y-m-d H:i:s',strtotime($follow['updated_at'])+(3600*8)):'';
2025-03-20 14:53:48 +08:00
// $follow = Util::formatDate($follow);
2025-03-14 14:27:33 +08:00
return $follow;
}
}