<?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]);
|
}
|
|
}
|