Skip to content

Commit

Permalink
Episode 95
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyWay committed Nov 9, 2017
1 parent c6d0b76 commit 5fb2436
Show file tree
Hide file tree
Showing 9 changed files with 316 additions and 39 deletions.
28 changes: 28 additions & 0 deletions app/Http/Controllers/SearchController.php
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers;

use App\{Thread, Trending};

class SearchController extends Controller
{
/**
* Show the search results.
*
* @param \App\Trending $trending
* @return mixed
*/
public function show(Trending $trending)
{
$threads = Thread::search(request('q'))->paginate(25);

if (request()->expectsJson()) {
return $threads;
}

return view('threads.index', [
'threads' => $threads,
'trending' => $trending->get()
]);
}
}
3 changes: 2 additions & 1 deletion app/Thread.php
Expand Up @@ -6,10 +6,11 @@
use App\Filters\ThreadFilters; use App\Filters\ThreadFilters;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;


class Thread extends Model class Thread extends Model
{ {
use RecordsActivity; use RecordsActivity, Searchable;


/** /**
* Don't auto-apply mass assignment protection. * Don't auto-apply mass assignment protection.
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Expand Up @@ -6,9 +6,11 @@
"type": "project", "type": "project",
"require": { "require": {
"php": ">=5.6.4", "php": ">=5.6.4",
"algolia/algoliasearch-client-php": "^1.23",
"barryvdh/laravel-debugbar": "^2.3", "barryvdh/laravel-debugbar": "^2.3",
"kitetail/zttp": "^0.3.0", "kitetail/zttp": "^0.3.0",
"laravel/framework": "5.5.*", "laravel/framework": "5.5.*",
"laravel/scout": "^3.0",
"laravel/tinker": "~1.0", "laravel/tinker": "~1.0",
"predis/predis": "^1.1" "predis/predis": "^1.1"
}, },
Expand Down

0 comments on commit 5fb2436

Please sign in to comment.