|
@@ -35,8 +35,8 @@ class CmsContentTemplateRepository {
|
|
|
*/
|
|
|
public function create($request)
|
|
|
{
|
|
|
- if($this->cmsContentTemplate->where('title', trim($request['title']))->exists()){
|
|
|
- throw new HttpException(500, '该模块已经存在');
|
|
|
+ if($this->cmsContentTemplate->where(['city_id'=>$request['city_id'],'title'=>trim($request['title'])])->exists()){
|
|
|
+ throw new HttpException(500, '当前城市该模块已经存在');
|
|
|
}
|
|
|
|
|
|
$subject = [
|
|
@@ -57,12 +57,23 @@ class CmsContentTemplateRepository {
|
|
|
*/
|
|
|
public function edit($request)
|
|
|
{
|
|
|
+ if ($request['is_open']==0){
|
|
|
+ $where = [
|
|
|
+ 'apply_type'=>$request['apply_type'],
|
|
|
+ 'is_open'=>$request['is_open'],
|
|
|
+ 'city_id'=>$request['city_id'],
|
|
|
+ ];
|
|
|
+ $template = $this->cmsContentTemplate->where($where)->get();
|
|
|
+ if (count($template)<1){
|
|
|
+ throw new HttpException(500, '同一城市同一模板必须有一个状态开启');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- $template = $this->cmsContentTemplate->find($request['id']);
|
|
|
- $template->is_open = $request['is_open'];
|
|
|
- $template->updated_at = date('Y-m-d H:i:s');
|
|
|
+ $template_id = $this->cmsContentTemplate->find($request['id']);
|
|
|
+ $template_id->is_open = $request['is_open'];
|
|
|
+ $template_id->updated_at = date('Y-m-d H:i:s');
|
|
|
|
|
|
- $res = $template->save();
|
|
|
+ $res = $template_id->save();
|
|
|
if (!$res) {
|
|
|
throw new HttpException(500, '修改状态失败');
|
|
|
}
|