From 1dcc5dfa2e0a82a5add8a2232371d42a543bacd6 Mon Sep 17 00:00:00 2001 From: merdiano Date: Wed, 11 Sep 2019 19:33:07 +0500 Subject: [PATCH] included breadcrumbs tnt scout for searchibng --- app/Http/Controllers/PublicController.php | 16 +-- app/Http/routes.php | 11 +- composer.json | 5 +- config/app.php | 5 +- config/breadcrumbs.php | 75 +++++++++++++ config/scout.php | 102 ++++++++++++++++++ ...5955_add_view_type_to_categories_table.php | 32 ++++++ .../Bilettm/Partials/BreadCrumbs.blade.php | 27 +++-- .../Bilettm/Partials/PublicHeader.blade.php | 8 +- .../Bilettm/Public/SearchResults.blade.php | 3 + .../Bilettm/ViewEvent/EventPage.blade.php | 2 +- routes/breadcrumbs.php | 11 ++ 12 files changed, 272 insertions(+), 25 deletions(-) create mode 100644 config/breadcrumbs.php create mode 100644 config/scout.php create mode 100644 database/migrations/2019_09_09_175955_add_view_type_to_categories_table.php create mode 100644 resources/views/Bilettm/Public/SearchResults.blade.php create mode 100644 routes/breadcrumbs.php diff --git a/app/Http/Controllers/PublicController.php b/app/Http/Controllers/PublicController.php index 5adc0395..78581b9e 100644 --- a/app/Http/Controllers/PublicController.php +++ b/app/Http/Controllers/PublicController.php @@ -8,7 +8,7 @@ namespace App\Http\Controllers; -use App\Http\Requests\Request; +use Illuminate\Http\Request; use App\Models\Category; use App\Models\Event; use App\Models\Slider; @@ -60,8 +60,7 @@ class PublicController extends Controller $nav_query->where('parent_id',$category->parent_id); $active_id = $category->id; } - else - { + else{ $e_query->where('category_id',$category->id); $nav_query->where('parent_id',$category->id); } @@ -78,9 +77,14 @@ class PublicController extends Controller $navigation = $nav_query->get(); return view('Bilettm.Public.EventsPage')->with([ - 'events'=>$events, - 'active_id'=>$active_id, - 'navigation'=>$navigation + 'events' => $events, + 'active_id' => $active_id, + 'navigation' => $navigation ]); } + + public function search(Request $request){ + $query = $request->get('q'); + return view('Bilettm.Public.SearchResult'); + } } \ No newline at end of file diff --git a/app/Http/routes.php b/app/Http/routes.php index 49fbc84e..1502eaeb 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -712,13 +712,22 @@ Route::group( ]); }); }); - Route::get('/','PublicController@showHomePage'); + + Route::get('/',[ + 'as' => 'home', + 'uses' => 'PublicController@showHomePage' + ]); // Route::get('/', function () { // return Redirect::route('showSelectOrganiser'); // // I prefer it that way: // // return Redirect::route('showOrganiserHome', ["organiser_id"=>1]); // }); + Route::get('/search',[ + 'as' => 'search', + 'uses' => 'PublicController@search' + ]); + Route::get('/terms_and_conditions', [ 'as' => 'termsAndConditions', function () { diff --git a/composer.json b/composer.json index a763600e..cd9a0e14 100755 --- a/composer.json +++ b/composer.json @@ -45,7 +45,10 @@ "backpack/backupmanager": "^1.4", "backpack/settings": "^2.1", "backpack/pagemanager": "^1.1", - "backpack/permissionmanager": "^4.0" + "backpack/permissionmanager": "^4.0", + "davejamesmiller/laravel-breadcrumbs": "5.3", + "teamtnt/tntsearch": "^2.1", + "teamtnt/laravel-scout-tntsearch-driver": "^7.2" }, diff --git a/config/app.php b/config/app.php index 22992ed0..da6d405b 100644 --- a/config/app.php +++ b/config/app.php @@ -171,7 +171,9 @@ return [ MaxHoffmann\Parsedown\ParsedownServiceProvider::class, Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class, - Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class + Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class, + Laravel\Scout\ScoutServiceProvider::class, + TeamTNT\Scout\TNTSearchScoutServiceProvider::class, ], /* @@ -236,6 +238,5 @@ return [ 'Markdown' => MaxHoffmann\Parsedown\ParsedownFacade::class, 'Omnipay' => Omnipay\Omnipay::class, 'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class, - ], ]; diff --git a/config/breadcrumbs.php b/config/breadcrumbs.php new file mode 100644 index 00000000..4e892e6d --- /dev/null +++ b/config/breadcrumbs.php @@ -0,0 +1,75 @@ + 'Bilettm.Partials.BreadCrumbs', + + /* + |-------------------------------------------------------------------------- + | Breadcrumbs File(s) + |-------------------------------------------------------------------------- + | + | The file(s) where breadcrumbs are defined. e.g. + | + | - base_path('routes/breadcrumbs.php') + | - glob(base_path('breadcrumbs/*.php')) + | + */ + + 'files' => base_path('routes/breadcrumbs.php'), + + /* + |-------------------------------------------------------------------------- + | Exceptions + |-------------------------------------------------------------------------- + | + | Determine when to throw an exception. + | + */ + + // When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException) + 'unnamed-route-exception' => true, + + // When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException) + 'missing-route-bound-breadcrumb-exception' => true, + + // When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException) + 'invalid-named-breadcrumb-exception' => true, + + /* + |-------------------------------------------------------------------------- + | Classes + |-------------------------------------------------------------------------- + | + | Subclass the default classes for more advanced customisations. + | + */ + + // Manager + 'manager-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsManager::class, + + // Generator + 'generator-class' => DaveJamesMiller\Breadcrumbs\BreadcrumbsGenerator::class, + +]; diff --git a/config/scout.php b/config/scout.php new file mode 100644 index 00000000..3cdf17b9 --- /dev/null +++ b/config/scout.php @@ -0,0 +1,102 @@ + env('SCOUT_DRIVER', 'algolia'), + + /* + |-------------------------------------------------------------------------- + | Index Prefix + |-------------------------------------------------------------------------- + | + | Here you may specify a prefix that will be applied to all search index + | names used by Scout. This prefix may be useful if you have multiple + | "tenants" or applications sharing the same search infrastructure. + | + */ + + 'prefix' => env('SCOUT_PREFIX', ''), + + /* + |-------------------------------------------------------------------------- + | Queue Data Syncing + |-------------------------------------------------------------------------- + | + | This option allows you to control if the operations that sync your data + | with your search engines are queued. When this is set to "true" then + | all automatic data syncing will get queued for better performance. + | + */ + + 'queue' => env('SCOUT_QUEUE', false), + + /* + |-------------------------------------------------------------------------- + | Chunk Sizes + |-------------------------------------------------------------------------- + | + | These options allow you to control the maximum chunk size when you are + | mass importing data into the search engine. This allows you to fine + | tune each of these chunk sizes based on the power of the servers. + | + */ + + 'chunk' => [ + 'searchable' => 500, + 'unsearchable' => 500, + ], + + /* + |-------------------------------------------------------------------------- + | Soft Deletes + |-------------------------------------------------------------------------- + | + | This option allows to control whether to keep soft deleted records in + | the search indexes. Maintaining soft deleted records can be useful + | if your application still needs to search for the records later. + | + */ + + 'soft_delete' => false, + + /* + |-------------------------------------------------------------------------- + | Algolia Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure your Algolia settings. Algolia is a cloud hosted + | search engine which works great with Scout out of the box. Just plug + | in your application ID and admin API key to get started searching. + | + */ + + 'algolia' => [ + 'id' => env('ALGOLIA_APP_ID', ''), + 'secret' => env('ALGOLIA_SECRET', ''), + ], + 'tntsearch' => [ + 'storage' => storage_path(), //place where the index files will be stored + 'fuzziness' => env('TNTSEARCH_FUZZINESS', false), + 'fuzzy' => [ + 'prefix_length' => 2, + 'max_expansions' => 50, + 'distance' => 2 + ], + 'asYouType' => false, + 'searchBoolean' => env('TNTSEARCH_BOOLEAN', false), + ], + +]; diff --git a/database/migrations/2019_09_09_175955_add_view_type_to_categories_table.php b/database/migrations/2019_09_09_175955_add_view_type_to_categories_table.php new file mode 100644 index 00000000..243e8cb4 --- /dev/null +++ b/database/migrations/2019_09_09_175955_add_view_type_to_categories_table.php @@ -0,0 +1,32 @@ +enum('view_type',['cinema','theatre','concert','exhibition','conference','other']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('categories', function (Blueprint $table) { + $table->dropColumn('view_type'); + }); + } +} diff --git a/resources/views/Bilettm/Partials/BreadCrumbs.blade.php b/resources/views/Bilettm/Partials/BreadCrumbs.blade.php index f93296f7..d0e4e62e 100644 --- a/resources/views/Bilettm/Partials/BreadCrumbs.blade.php +++ b/resources/views/Bilettm/Partials/BreadCrumbs.blade.php @@ -1,17 +1,24 @@ +@if (count($breadcrumbs)) \ No newline at end of file + +@endif \ No newline at end of file diff --git a/resources/views/Bilettm/Partials/PublicHeader.blade.php b/resources/views/Bilettm/Partials/PublicHeader.blade.php index 4bef3a1e..5be098da 100644 --- a/resources/views/Bilettm/Partials/PublicHeader.blade.php +++ b/resources/views/Bilettm/Partials/PublicHeader.blade.php @@ -22,10 +22,10 @@ diff --git a/resources/views/Bilettm/Public/SearchResults.blade.php b/resources/views/Bilettm/Public/SearchResults.blade.php new file mode 100644 index 00000000..603f3fd1 --- /dev/null +++ b/resources/views/Bilettm/Public/SearchResults.blade.php @@ -0,0 +1,3 @@ +@extends('Bilettm.Layouts.BilettmLayout') +@section('content') +@endsection diff --git a/resources/views/Bilettm/ViewEvent/EventPage.blade.php b/resources/views/Bilettm/ViewEvent/EventPage.blade.php index d51bc7de..e86bbdb6 100644 --- a/resources/views/Bilettm/ViewEvent/EventPage.blade.php +++ b/resources/views/Bilettm/ViewEvent/EventPage.blade.php @@ -1,6 +1,6 @@ @extends('Bilettm.Layouts.BilettmLayout') @section('content') - @include('Bilettm.Partials.BreadCrumbs') + {{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('home')}}
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php new file mode 100644 index 00000000..1d9c1146 --- /dev/null +++ b/routes/breadcrumbs.php @@ -0,0 +1,11 @@ +push('Home', route('home')); +}); \ No newline at end of file