This commit is contained in:
commie
2026-02-15 19:41:56 +08:00
parent 61c5192018
commit 1a7f4bc98a
68 changed files with 992 additions and 353 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace app\model;
/**
* 相册模型
* @property integer $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 Album extends Base
{
protected $name = 'album';
protected function getOptions(): array
{
return array_merge(parent::getOptions(), [
'insert' => [
'status' => 1,
],
]);
}
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');
}
}