|
| xqd
@@ -58,10 +58,21 @@ class DynamicService
|
|
|
|
|
|
foreach ($tag as $v){
|
|
|
if($v['id']==0){
|
|
|
- $id = DB::table('dynamic_tag')->insertGetId([
|
|
|
- "title"=>htmlspecialchars($v['title']),
|
|
|
- "hot"=>1
|
|
|
- ]);
|
|
|
+ if(!empty($v['title'])){
|
|
|
+ if($tag = DB::table('dynamic_tag')->where('title',$v['title'])->first()){
|
|
|
+ DB::table('dynamic_tag')->where(['id'=>$tag->id])->increment('hot',1);
|
|
|
+ $id = $tag->id;
|
|
|
+ }else{
|
|
|
+ $id = DB::table('dynamic_tag')->insertGetId([
|
|
|
+ "title"=>htmlspecialchars($v['title']),
|
|
|
+ "hot"=>1
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new Exception("请输入话题内容");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$tag_ins.= $id.',';
|
|
|
}else{
|
|
|
DB::table('dynamic_tag')->where(['id'=>$v['id']])->increment('hot',1);
|