|
@@ -19,8 +19,6 @@ class CmsContentTemplateRepository {
|
|
|
|
|
|
if (isset($request['is_open'])){
|
|
|
$where[] = ['is_open','=',$request['is_open']];
|
|
|
- }else{
|
|
|
- $where[] = ['is_open', '=',1];
|
|
|
}
|
|
|
|
|
|
if (isset($request['city_id'])){
|
|
@@ -28,7 +26,12 @@ class CmsContentTemplateRepository {
|
|
|
'city_id','=',$request['city_id'],
|
|
|
];
|
|
|
}
|
|
|
- return $this->cmsContentTemplate->where($where)->where('status',1)->orderBy('id', 'asc')->paginate($perPage);
|
|
|
+ if (isset($request['status'])){
|
|
|
+ $where[] = [
|
|
|
+ 'status','=',$request['status'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ return $this->cmsContentTemplate->where($where)->orderBy('id', 'asc')->paginate($perPage);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -38,17 +41,10 @@ class CmsContentTemplateRepository {
|
|
|
*/
|
|
|
public function create($request)
|
|
|
{
|
|
|
- $where = ['city_id'=>$request['city_id'],'title'=>trim($request['title']),'apply_type'=>$request['apply_type']];
|
|
|
+ $where = ['city_id'=>$request['city_id'],'apply_type'=>$request['apply_type']];
|
|
|
$template = $this->cmsContentTemplate->where($where)->get();
|
|
|
- if (count($template) == 2){
|
|
|
- throw new HttpException(500, '每个城市只能存在两个相同的模版');
|
|
|
- }
|
|
|
- foreach ($template->toArray() as $k=>$v){
|
|
|
- if ($v['is_open'] == 1){
|
|
|
- $request['is_open'] = 0;
|
|
|
- }else{
|
|
|
- $request['is_open'] = 1;
|
|
|
- }
|
|
|
+ if (count($template) == 1){
|
|
|
+ throw new HttpException(500, '当前城市该模版类型已存在');
|
|
|
}
|
|
|
|
|
|
$subject = [
|
|
@@ -56,9 +52,13 @@ class CmsContentTemplateRepository {
|
|
|
'city_id' => $request['city_id'],
|
|
|
'city_name' => $request['city_name'],
|
|
|
'apply_type' => $request['apply_type'],
|
|
|
- 'is_open' => $request['is_open'] ?? 0,
|
|
|
- 'status' => 1
|
|
|
+ 'is_open' => 0,
|
|
|
+ 'status' => 0
|
|
|
];
|
|
|
+ if ($request['city_id'] == 610100){
|
|
|
+ $subject['is_open'] = 1;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if (!$this->cmsContentTemplate->create($subject)) {
|
|
|
throw new HttpException(500, '添加失败');
|
|
@@ -71,13 +71,13 @@ class CmsContentTemplateRepository {
|
|
|
public function edit($request)
|
|
|
{
|
|
|
$template_id = $this->cmsContentTemplate->find($request['id']);
|
|
|
- $where = ['city_id'=>$template_id->city_id,'title'=>$template_id->title,'apply_type'=>$template_id->apply_type];
|
|
|
+ $where = ['city_id'=>$template_id->city_id,'apply_type'=>$template_id->apply_type];
|
|
|
$template = $this->cmsContentTemplate->where($where)->get();
|
|
|
-// foreach ($template->toArray() as $v){
|
|
|
-// if ($v['is_open'] == 1 && $request['is_open'] == 0){
|
|
|
-// throw new HttpException(500, '请先关闭该城市模块下已开启的模板后操作');
|
|
|
-// }
|
|
|
-// }
|
|
|
+ foreach ($template->toArray() as $v){
|
|
|
+ if ($v['is_open'] == 1 && $request['is_open'] == 0){
|
|
|
+ throw new HttpException(500, '请先关闭该城市模块下已开启的模板后操作');
|
|
|
+ }
|
|
|
+ }
|
|
|
if ($request['city_id'] == 610100 && $request['is_open'] == 0){
|
|
|
throw new HttpException(500, '城市为西安的模板不允许手动关闭');
|
|
|
}
|