From 0532bbac0c70c720afd03853898e579825963565 Mon Sep 17 00:00:00 2001 From: Christopher Chan Date: Sun, 22 Nov 2015 02:18:03 -0500 Subject: [PATCH] Initialize elasticsearch (#8) --- .env.example | 3 ++ app/Http/Controllers/Api/SearchController.php | 6 ++++ app/Providers/SearchProvider.php | 31 +++++++++++++++++++ app/Search/Search.php | 21 +++++++++++++ config/app.php | 1 + 5 files changed, 62 insertions(+) create mode 100644 app/Providers/SearchProvider.php create mode 100644 app/Search/Search.php diff --git a/.env.example b/.env.example index 8eb8f57..7d0b041 100644 --- a/.env.example +++ b/.env.example @@ -17,3 +17,6 @@ MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null + +ES_HOST=localhost +ES_INDEX=dino \ No newline at end of file diff --git a/app/Http/Controllers/Api/SearchController.php b/app/Http/Controllers/Api/SearchController.php index a6b0e7e..c6e6999 100644 --- a/app/Http/Controllers/Api/SearchController.php +++ b/app/Http/Controllers/Api/SearchController.php @@ -7,9 +7,15 @@ use App\Http\Requests; use App\Http\Controllers\Controller; +use App\Search\Search; class SearchController extends Controller { + + public function __construct(Search $search) + { + var_dump($search); + } /** * Display a listing of the resource. * diff --git a/app/Providers/SearchProvider.php b/app/Providers/SearchProvider.php new file mode 100644 index 0000000..9b7bbe6 --- /dev/null +++ b/app/Providers/SearchProvider.php @@ -0,0 +1,31 @@ +app->bind('App\Search\Search', function() { + return new Search(); + }); + } +} diff --git a/app/Search/Search.php b/app/Search/Search.php new file mode 100644 index 0000000..74d9c50 --- /dev/null +++ b/app/Search/Search.php @@ -0,0 +1,21 @@ +setHosts([env('ES_HOST')])->build(); + } +} \ No newline at end of file diff --git a/config/app.php b/config/app.php index 7dcfe2d..67fb49a 100644 --- a/config/app.php +++ b/config/app.php @@ -144,6 +144,7 @@ App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, + App\Providers\SearchProvider::class, ],