This commit is contained in:
2026-04-04 08:52:59 +08:00
parent 66bcd8061a
commit d98ac8f146
33 changed files with 2565 additions and 328 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace app\model;
/**
* 相册模型
* @property integer $id 主键(ID)
* @property integer $album_id 用户ID
* @property integer $user_id 用户ID
* @property integer $group_id 内容
* @property string $url 图片
* @property string $title 标题
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态(0:隐藏 1:正常)
*/
class Gallery extends Base
{
protected $name = 'gallery';
protected function getOptions(): array
{
return array_merge(parent::getOptions(), [
'insert' => [
'status' => 1,
],
'append'=>[
'userID',
'groupID'
]
]);
}
function getGroupIDAttr($v,$row){
return $v?:$row['group_id'];
}
function getUserIDAttr($v,$row){
return $v?:$row['user_id'];
}
public static function onAfterInsert($row){
$changeData = $row->getChangedData();
if(isset($changeData['url'])) {
Files::where('path',$changeData['url'])->inc('use_count');
};
}
public static function onAfterUpdate($row){
$OrgData = $row->getOrigin();
$changeData = $row->getChangedData();
if(isset($OrgData['url']) && $OrgData['url']) {
\support\Log::info('OrgData string');
Files::where('path',$OrgData['url'])->dec('use_count');
};
if(isset($changeData['url']) && $changeData['url']) {
\support\Log::info('changeData string');
Files::where('path',$changeData['url'])->inc('use_count');
};
}
public static function onAfterDelete($row){
Files::where('path',$row->url)->dec('use_count');
}
}