Return正常结果tnt搜索
Return normal result tnt search
如果这是一个新手问题,我很抱歉。
我在我的应用程序中使用 tntseach 作为我的 laravel-scout 驱动程序和搜索系统。
它目前运行良好,但唯一的问题是我收到结果的格式。
如果我搜索 "video" 即 http://localhost:8000/search?q=video
我得到 ["Video post"] as the result.It is correct but I want the result to be just
视频 post` 即省略括号和双引号。
如果我搜索 "posts"
我得到:
["My first post","Video post","Posts"]
我希望它是:
My first posts
Video post
posts
我试过 json_decode()
但没用,可能是因为它不是真的 json。
这是我的SearchController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\Post;
use TeamTNT\TNTSearch\TNTSearch;
class SearchController extends Controller
{
/**
* Display the main dashboard page.
*
* @return \Illuminate\Http\Response
*/
public function search(Request $request){
$posts = Post::search($request->input('q'))->get('titlek')->pluck('title');
return view('search.index', compact('posts'));
}
}
这是我的 search.blade.php:
@extends('layouts.base')
@section('pageTitle', 'Login')
@section('content')
Your search results are:<br><br>
{{ $posts }}
@endsection
由于结果是一个数组,所以需要遍历数组并显示每个
@section('content')
Your search results are:<br>
@foreach($posts as $post)
{{ $post }}<br>
@endforeach
@endsection
如果这是一个新手问题,我很抱歉。
我在我的应用程序中使用 tntseach 作为我的 laravel-scout 驱动程序和搜索系统。
它目前运行良好,但唯一的问题是我收到结果的格式。
如果我搜索 "video" 即 http://localhost:8000/search?q=video
我得到 ["Video post"] as the result.It is correct but I want the result to be just
视频 post` 即省略括号和双引号。
如果我搜索 "posts"
我得到:
["My first post","Video post","Posts"]
我希望它是:
My first posts
Video post
posts
我试过 json_decode()
但没用,可能是因为它不是真的 json。
这是我的SearchController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\User;
use App\Post;
use TeamTNT\TNTSearch\TNTSearch;
class SearchController extends Controller
{
/**
* Display the main dashboard page.
*
* @return \Illuminate\Http\Response
*/
public function search(Request $request){
$posts = Post::search($request->input('q'))->get('titlek')->pluck('title');
return view('search.index', compact('posts'));
}
}
这是我的 search.blade.php:
@extends('layouts.base')
@section('pageTitle', 'Login')
@section('content')
Your search results are:<br><br>
{{ $posts }}
@endsection
由于结果是一个数组,所以需要遍历数组并显示每个
@section('content')
Your search results are:<br>
@foreach($posts as $post)
{{ $post }}<br>
@endforeach
@endsection