mirror of
https://gitee.com/ulthon/ul-file-share.git
synced 2026-07-08 21:52:48 +08:00
完成基本功能
This commit is contained in:
@@ -12,4 +12,33 @@ use think\Model;
|
||||
class Share extends Model
|
||||
{
|
||||
//
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->hasMany(ShareFiles::class,'share_id');
|
||||
}
|
||||
|
||||
public function getExpireDateAttr()
|
||||
{
|
||||
|
||||
$date = date('Y-m-d H:i:s', $this->getAttr('expire_time'));
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getTotalSizeFormatAttr()
|
||||
{
|
||||
return format_size($this->getData('total_size'));
|
||||
}
|
||||
|
||||
public function getExpireTimeAttr()
|
||||
{
|
||||
$exipre = $this->getData('expire');
|
||||
return $this->getOrigin('create_time') + $exipre;
|
||||
}
|
||||
|
||||
public function getReadUrlAttr()
|
||||
{
|
||||
return url('Index/read', ['uid' => $this->getData('uid')], false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,5 +21,11 @@ class ShareFiles extends Model
|
||||
|
||||
return $root_dir . $safe_dir . $save_name;
|
||||
}
|
||||
|
||||
public function getFileSizeFormatAttr()
|
||||
{
|
||||
$value = $this->getData('file_size');
|
||||
return format_size($value);
|
||||
}
|
||||
//
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user