<?php
|
|
namespace app\operations\model\plus\regactivity;
|
|
use app\common\model\plus\regactivity\Activity as ActivityModel;
|
|
/**
|
* 文章模型
|
*/
|
class Activity extends ActivityModel
|
{
|
/**
|
* 获取列表
|
*/
|
public function getList($params)
|
{
|
return $this->with(['image', 'category'])
|
->where('is_delete', '=', 0)
|
->order(['activity_sort' => 'asc', 'create_time' => 'desc'])
|
->paginate($params);
|
|
}
|
|
/**
|
* 新增记录
|
*/
|
public function add($data)
|
{
|
$data['app_id'] = self::$app_id;
|
//报名时间
|
$data['register_start_time'] = strtotime($data['reg_date'][0]);
|
$data['register_end_time'] = strtotime($data['reg_date'][1]);
|
//活动时间
|
$data['activity_start_time'] = strtotime($data['act_date'][0]);
|
$data['activity_end_time'] = strtotime($data['act_date'][1]);
|
// 格式化坐标信息
|
$coordinate = explode(',', $data['coordinate']);
|
$data['latitude'] = $coordinate[0];
|
$data['longitude'] = $coordinate[1];
|
return $this->save($data);
|
}
|
|
/**
|
* 更新记录
|
*/
|
public function edit($data)
|
{
|
//报名时间
|
$data['register_start_time'] = strtotime($data['reg_date'][0]);
|
$data['register_end_time'] = strtotime($data['reg_date'][1]);
|
//活动时间
|
$data['activity_start_time'] = strtotime($data['act_date'][0]);
|
$data['activity_end_time'] = strtotime($data['act_date'][1]);
|
// 格式化坐标信息
|
$coordinate = explode(',', $data['coordinate']);
|
$data['latitude'] = $coordinate[0];
|
$data['longitude'] = $coordinate[1];
|
return $this->save($data);
|
}
|
|
/**
|
* 软删除
|
*/
|
public function setDelete()
|
{
|
return $this->save(['is_delete' => 1]);
|
}
|
|
/**
|
* 获取活动总数量
|
*/
|
public static function getActivityTotal($where)
|
{
|
$model = new static;
|
return $model->where($where)->where('is_delete', '=', 0)->count();
|
}
|
}
|