bestmomo / laravel5-example

Simple laravel5 example for tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search doesn't display results

geosem42 opened this issue · comments

I just changed the design and reverted back to default bootstrap. I haven't changed anything else other than the views. It looks like everything is working, from comments, blog posts, approving comments... except the search.

If I search for Post 1 I get a blue notification saying Posts found with search Post 1 but it displays no results. If I search for jdfghgh I get the same thing.

"Post 1" is not in content. Did you try some word like "tempus" ?

Oooohhh, it indexes the content only.
Yes, it's working now. How do I add the title to be also searchable?

The query is in BlogRepository :

/**
 * Get search collection.
 *
 * @param  int  $n
 * @param  string  $search
 * @return Illuminate\Support\Collection
 */
public function search($n, $search)
{
    $query = $this->queryActiveWithUserOrderByDate();

    return $query->where(function($q) use ($search) {
        $q->where('summary', 'like', "%$search%")
            ->orWhere('content', 'like', "%$search%");
    })->paginate($n);
}

You can add title there.