Browse Source

文章搜索

linwu 2 năm trước cách đây
mục cha
commit
b0e5051e47
1 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 5 3
      app/Services/Content/ArticleService.php

+ 5 - 3
app/Services/Content/ArticleService.php

@@ -4,6 +4,7 @@ namespace App\Services\Content;
 use App\Repositories\ArticleRepository;
 use App\Repositories\ArticlePropertyReoository;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
 
 class ArticleService
 {
@@ -37,13 +38,14 @@ class ArticleService
         }
 
         if ($id) {
-            $where[] = array('type_id','=',$id);
-            $where[] = array('parent_id','=',$id);
+            $where[] = [function($query)use($id){
+                $query->where('type_id',$id)->orWhere('parent_id',$id);
+            }];
             $list=$this->articleRepository->getArticles($where, $page);
         } else {
             $or_map = $map;
             $or_map[] = array('type_id','=','1');
-//            $map[] = array('parent_id','=','1');
+            $map[] = array('parent_id','=','1');
             $list=$this->articleRepository->getAllArticles($map, $or_map, $page);
         }
         if ($list->toArray()) {