|
|
@@ -12,6 +12,7 @@
|
|
|
namespace App\Services;
|
|
|
|
|
|
use App\Models\ArticleModel;
|
|
|
+use App\Models\CollectModel;
|
|
|
use App\Models\MemberModel;
|
|
|
|
|
|
/**
|
|
|
@@ -197,7 +198,7 @@ class ArticleService extends BaseService
|
|
|
* 获取详情
|
|
|
* @param $id
|
|
|
*/
|
|
|
- public function getDetail($id){
|
|
|
+ public function getDetail($id, $userId=0){
|
|
|
$info = $this->model::from('article as a')
|
|
|
->leftJoin('article_cates as c', 'a.cate_id', '=', 'c.id')
|
|
|
->where(['a.mark'=> 1,'a.status'=> 1,'a.id'=> $id])
|
|
|
@@ -213,6 +214,14 @@ class ArticleService extends BaseService
|
|
|
$author = MemberModel::where(['id'=> $info['user_id']])->value('nickname');
|
|
|
$info['author'] = $author? $author : '报恩寺';
|
|
|
}
|
|
|
+
|
|
|
+ // 是否已收藏
|
|
|
+ $info['is_collect'] = 0;
|
|
|
+ if($userId){
|
|
|
+ if(CollectModel::where(['user_id'=> $userId,'source_id'=> $id,'type'=> 1,'mark'=> 1,'status'=> 1])->value('id')){
|
|
|
+ $info['is_collect'] = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return $info;
|
|
|
}
|