20
This commit is contained in:
+27
-9
@@ -5,9 +5,12 @@ namespace app\model;
|
||||
* 相册模型
|
||||
* @property integer $id 主键(ID)
|
||||
* @property integer $user_id 用户ID
|
||||
* @property integer $group_id 内容
|
||||
* @property string $url 图片
|
||||
* @property integer $group_id 群组ID
|
||||
* @property integer $userID 用户ID
|
||||
* @property integer $groupID 群组ID
|
||||
* @property string $title 标题
|
||||
* @property int $image 封面图片ID
|
||||
* @property int $weigh 排序权重,越小越靠前
|
||||
* @property integer $created_at 创建时间
|
||||
* @property integer $updated_at 更新时间
|
||||
* @property integer $status 状态(0:隐藏 1:正常)
|
||||
@@ -22,30 +25,45 @@ class Album extends Base
|
||||
'insert' => [
|
||||
'status' => 1,
|
||||
],
|
||||
'append'=>[
|
||||
'userID',
|
||||
'groupID'
|
||||
]
|
||||
]);
|
||||
}
|
||||
public static function onAfterInsert($row){
|
||||
$changeData = $row->getChangedData();
|
||||
if(isset($changeData['url'])) {
|
||||
Files::where('path',$changeData['url'])->inc('use_count');
|
||||
if(isset($changeData['image'])) {
|
||||
Files::where('path',$changeData['image'])->inc('use_count');
|
||||
};
|
||||
}
|
||||
|
||||
public static function onAfterUpdate($row){
|
||||
$OrgData = $row->getOrigin();
|
||||
$changeData = $row->getChangedData();
|
||||
if(isset($OrgData['url']) && $OrgData['url']) {
|
||||
if(isset($OrgData['image']) && $OrgData['image']) {
|
||||
\support\Log::info('OrgData string');
|
||||
Files::where('path',$OrgData['url'])->dec('use_count');
|
||||
Files::where('path',$OrgData['image'])->dec('use_count');
|
||||
};
|
||||
if(isset($changeData['url']) && $changeData['url']) {
|
||||
if(isset($changeData['image']) && $changeData['image']) {
|
||||
\support\Log::info('changeData string');
|
||||
Files::where('path',$changeData['url'])->inc('use_count');
|
||||
Files::where('path',$changeData['image'])->inc('use_count');
|
||||
};
|
||||
}
|
||||
|
||||
public static function onBeforeDelete($row){
|
||||
if($row->total>0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static function onAfterDelete($row){
|
||||
Files::where('path',$row->url)->dec('use_count');
|
||||
Files::where('path',$row->image)->dec('use_count');
|
||||
}
|
||||
function getGroupIDAttr($v,$row){
|
||||
return $v?:$row['group_id'];
|
||||
}
|
||||
function getUserIDAttr($v,$row){
|
||||
return $v?:$row['user_id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user