Skip to content

Commit

Permalink
Episode 98
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Nov 28, 2017
1 parent 7344c1a commit 088fc66
Show file tree
Hide file tree
Showing 9 changed files with 58,146 additions and 35,126 deletions.
7 changes: 2 additions & 5 deletions app/Http/Controllers/SearchController.php
Expand Up @@ -14,14 +14,11 @@ class SearchController extends Controller
*/ */
public function show(Trending $trending) public function show(Trending $trending)
{ {
$threads = Thread::search(request('q'))->paginate(25);

if (request()->expectsJson()) { if (request()->expectsJson()) {
return $threads; return Thread::search(request('q'))->paginate(25);
} }


return view('threads.index', [ return view('threads.search', [
'threads' => $threads,
'trending' => $trending->get() 'trending' => $trending->get()
]); ]);
} }
Expand Down
10 changes: 10 additions & 0 deletions app/Thread.php
Expand Up @@ -220,4 +220,14 @@ public function markBestReply(Reply $reply)
{ {
$this->update(['best_reply_id' => $reply->id]); $this->update(['best_reply_id' => $reply->id]);
} }

/**
* Get the indexable data array for the model.
*
* @return array
*/
public function toSearchableArray()
{
return $this->toArray() + ['path' => $this->path()];
}
} }
1 change: 1 addition & 0 deletions config/scout.php
Expand Up @@ -72,6 +72,7 @@


'algolia' => [ 'algolia' => [
'id' => env('ALGOLIA_APP_ID', ''), 'id' => env('ALGOLIA_APP_ID', ''),
'key' => env('ALGOLIA_KEY', ''),
'secret' => env('ALGOLIA_SECRET', ''), 'secret' => env('ALGOLIA_SECRET', ''),
], ],


Expand Down
171 changes: 147 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -19,6 +19,7 @@
"dependencies": { "dependencies": {
"at.js": "^1.5.3", "at.js": "^1.5.3",
"jquery.caret": "^0.3.1", "jquery.caret": "^0.3.1",
"moment": "^2.18.1" "moment": "^2.18.1",
"vue-instantsearch": "^1.3.2"
} }
} }

0 comments on commit 088fc66

Please sign in to comment.