liyaozhi
2025-10-29 52b7c373601edbc5010471082eb88dadf70e382d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
 
namespace app\api\model\branch;
 
use app\common\exception\BaseException;
use app\common\model\branch\ActivityFile as ActivityFileModel;
 
/**
 * 活动文件模型
 */
class ActivityFile extends ActivityFileModel
{
    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [
        'is_delete',
        'app_id',
        'update_time'
    ];
    
    /**
     * 获取列表
     */
    public function getList($activity_id, $params)
    {
        $model = $this;
        $file_type = !empty($params['file_type']) ? $params['file_type'] : 'image';
        return $model ->with(['file'])
            ->where('activity_id', '=', $activity_id)
            ->where('file_type', '=', $file_type)
            ->where('is_delete', '=', 0)
            ->order(['sort' => 'desc', 'create_time' => 'desc'])
            ->paginate($params);
    }
 
    /**
     * 新增记录
     */
    public function add($data)
    {
        foreach ($data as &$item) {
            $item['app_id'] = self::$app_id;
        }
        return $this->saveAll($data);
    }
 
    /**
     * 删除
     */
    public function setDelete($fileIds)
    {
        // return $this->save(['is_delete' => 1]);
        return $this->where('file_id', 'in', $fileIds)->update(['is_delete' => 1]);
    }
 
}