| xqd
@@ -9,6 +9,7 @@ use App\Http\Params\DynamicParam;
|
|
|
use App\Http\Params\DynamicZanParam;
|
|
|
use App\Http\Params\UserReportParam;
|
|
|
use App\Models\DynamicModel;
|
|
|
+use App\Models\DynamicTag;
|
|
|
use App\Models\DynamicZanModel;
|
|
|
use App\Models\User;
|
|
|
use App\Models\UserBlacklistModel;
|
| xqd
@@ -26,7 +27,7 @@ class DynamicService
|
|
|
if(!empty($keyword)){
|
|
|
$query = $query->where("title","like","%{$keyword}%");
|
|
|
}
|
|
|
- $query = $query->where("type",$type)
|
|
|
+ $query = $query->where(["type"=>$type,'is_delete'=>0])
|
|
|
->orderBy("hot","desc")
|
|
|
->limit(20)
|
|
|
->get();
|
| xqd
@@ -39,6 +40,25 @@ class DynamicService
|
|
|
return $query;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //删除话题
|
|
|
+ public function del_tag($id){
|
|
|
+ $user = auth('api')->user();
|
|
|
+ if(empty($id)){
|
|
|
+ throw new Exception('参数错误');
|
|
|
+ }
|
|
|
+ $tag = DynamicTag::query()->where(['id'=>$id])->first();
|
|
|
+ if(!$tag){
|
|
|
+ throw new Exception('话题不存在');
|
|
|
+ }
|
|
|
+ if($tag->user_id!=$user->id){
|
|
|
+ throw new Exception('只能删除自己的话题');
|
|
|
+ }
|
|
|
+ $tag->delete = 1;
|
|
|
+ $tag->save();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 发布动态
|
|
|
*/
|
| xqd
@@ -79,7 +99,8 @@ class DynamicService
|
|
|
$id = DB::table('dynamic_tag')->insertGetId([
|
|
|
"title"=>htmlspecialchars($v['title']),
|
|
|
"hot"=>1,
|
|
|
- "type"=>1
|
|
|
+ "type"=>1,
|
|
|
+ "user_id"=>$user->id,
|
|
|
]);
|
|
|
}
|
|
|
}else{
|