65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
|
|
use app\service\OssService;
|
|
use app\util\Util;
|
|
use config\constants\Constants;
|
|
use support\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Follow extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'follow';
|
|
|
|
/**
|
|
* 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 $dates = ['created_at', 'updated_at', 'follow_time'];
|
|
|
|
protected $casts = [
|
|
'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', // 指定序列化格式
|
|
];
|
|
|
|
public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com')
|
|
{
|
|
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
|
|
$follow['firstFollowtime'] = $follow['follow_time'];
|
|
if (isset($follow['follow_time']) && !empty($follow['follow_time'])) {
|
|
$ossservice = new OssService();
|
|
$oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400);
|
|
$follow['oss_picture'] = $oss_picture;
|
|
}else {
|
|
$follow['oss_picture'] = '';
|
|
}
|
|
// $follow = Util::formatDate($follow);
|
|
return $follow;
|
|
}
|
|
} |