public static function getPosts($post_id) { $photo_id = Post::where('post_id', $post_id)->get(['photo_link'])[0]["photo_link"]; $list_id = PostRecommendView::where("photo_id", $photo_id)->orderBy("rank", "desc")->take(10)->get(["post_id_recommend"]); $results = UserPosts::whereIn("post_id", $list_id)->distinct('photo_link')->get(); return $results; }
public function getPost($post_id) { // $client = new Client(); // $post = Post::getPostById($post_id); // $index_name = Config::get('elasticsearch.index_name'); // $post_type = Config::get('elasticsearch.post_type'); // $params = [ // "index"=>$index_name, // "analyzer"=>'vi_analyzer', // 'text'=>$post["description"] // ]; // $tokens = $client->indices()->analyze($params)["tokens"]; // $search = new SearchController(); // $results = []; // foreach($tokens as $token){ // $query = ["description"=>$token["token"]]; // $results[] = $search->search($post_type,$query); $results = PostRecommendView::getPosts($post_id); return $results; }