where('is_delete', '=', 0) ->order(['sort' => 'asc', 'create_time' => 'desc']) ->paginate(15, false, [ 'query' => request()->request() ]); } /** * 添加新记录 * @param $data * @return false|int */ public function add($data) { $data['wxapp_id'] = self::$wxapp_id; if ($data['expire_type'] == '20') { $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); } $data['apply_range_config'] = isset($data['apply_range_config']) ? $data['apply_range_config'] : []; return $this->allowField(true)->save($data); } /** * 更新记录 * @param $data * @return bool|int */ public function edit($data) { if ($data['expire_type'] == '20') { $data['start_time'] = strtotime($data['start_time']); $data['end_time'] = strtotime($data['end_time']); } return $this->allowField(true)->save($data) !== false; } /** * 删除记录 (软删除) * @return bool|int */ public function setDelete() { return $this->save(['is_delete' => 1]) !== false; } }