duqinya il y a 6 ans
Parent
commit
fd70a960ea
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      app/Repositories/CmsContentTemplateSetRepository.php

+ 6 - 2
app/Repositories/CmsContentTemplateSetRepository.php

@@ -39,6 +39,7 @@ class CmsContentTemplateSetRepository {
                 $need_create = false;
                 $request['type'] = $v['apply_type'];
                 $request['tpl_id'] = $v['id'];
+                $request['city_id'] = $v['city_id'];
                 return $this->preview($request);
             }
         }
@@ -72,7 +73,8 @@ class CmsContentTemplateSetRepository {
                                 throw new HttpException(500, '生成模板内容失败');
                             }
                             $request['type'] = $res->apply_type;
-                            $request['tpl_id'] = $result->tpl_id;
+                            $request['tpl_id'] = $res->id;
+                            $request['city_id'] = $res->city_id;
                         }
                     }
                     DB::commit();
@@ -338,7 +340,7 @@ class CmsContentTemplateSetRepository {
      */
     public function preview($request)
     {
-
+        $temalate = $this->cmsContentTemplate->select('id','title','apply_type')->where(['status'=>0,'city_id'=>$request['city_id'],'deleted_at'=>null])->orderBy('apply_type','asc')->get();
         $temalates = $this->cmsContentTemplate->select('title')->where(['id'=>$request['tpl_id']])->first();
         if (!$temalates){
             throw new HttpException(500, '没有找到对应模板');
@@ -350,11 +352,13 @@ class CmsContentTemplateSetRepository {
             $group_array['apply_type'] = 0;
             $group_array['tpl_id'] = $request['tpl_id'];
             $group_array['title'] = $temalates->title;
+            $group_array['template'] = $temalate->toArray();
             $group_array['content'] =[];
         }else{//菜市场首页
             $group_array['apply_type'] = 1;
             $group_array['tpl_id'] = $request['tpl_id'];
             $group_array['title'] = $temalates->title;
+            $group_array['template'] = $temalate->toArray();
             $group_array['content'] =[];
         }