included breadcrumbs tnt scout for searchibng

This commit is contained in:
merdiano 2019-09-11 19:33:07 +05:00
parent 571218b21b
commit 1dcc5dfa2e
12 changed files with 272 additions and 25 deletions

View File

@ -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');
}
}

View File

@ -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 () {

View File

@ -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"
},

View File

@ -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,
],
];

75
config/breadcrumbs.php Normal file
View File

@ -0,0 +1,75 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| View Name
|--------------------------------------------------------------------------
|
| Choose a view to display when Breadcrumbs::render() is called.
| Built in templates are:
|
| - 'breadcrumbs::bootstrap4' - Bootstrap 4
| - 'breadcrumbs::bootstrap3' - Bootstrap 3
| - 'breadcrumbs::bootstrap2' - Bootstrap 2
| - 'breadcrumbs::bulma' - Bulma
| - 'breadcrumbs::foundation6' - Foundation 6
| - 'breadcrumbs::materialize' - Materialize
| - 'breadcrumbs::uikit' - UIkit
| - 'breadcrumbs::json-ld' - JSON-LD Structured Data
|
| Or a custom view, e.g. '_partials/breadcrumbs'.
|
*/
'view' => '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,
];

102
config/scout.php Normal file
View File

@ -0,0 +1,102 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Search Engine
|--------------------------------------------------------------------------
|
| This option controls the default search connection that gets used while
| using Laravel Scout. This connection is used when syncing all models
| to the search service. You should adjust this based on your needs.
|
| Supported: "algolia", "null"
|
*/
'driver' => 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),
],
];

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddViewTypeToCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('categories', function (Blueprint $table) {
$table->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');
});
}
}

View File

@ -1,17 +1,24 @@
@if (count($breadcrumbs))
<section class="page-breadcrumbs">
<div class="container">
<div class="row">
<ul>
@foreach ($breadcrumbs as $breadcrumb)
@if ($breadcrumb->url && !$loop->last)
<li>
<a href="">Главная</a>
<a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a>
</li>
<li>
<i class="fa fa-caret-right"></i>
</li>
@else
<li class="page-name">
<a href="">Кино</a>
{{ $breadcrumb->title }}
</li>
@endif
@endforeach
</ul>
</div>
</div>
</section>
@endif

View File

@ -22,10 +22,10 @@
<!-- Navigation -->
<div id="navBar" style="width: 40%;" class="collapse navbar-collapse align-items-center flex-sm-row g-pt-15 g-pt-0--lg row">
<div class="col-12 search-panel w-100">
<form action="">
<form action="{{route('search')}}" method="GET">
<div class="form-group">
<input type="text" class="form-control" placeholder="Поиск...">
<a href="" id="top-header-submit"><img src="{{asset('assets/images/icons/search.svg')}}"></a>
<input type="text" class="form-control" name="q" placeholder="Мероприятия, исполнители, площадки">
<button id="top-header-submit"><img src="{{asset('assets/images/icons/search.svg')}}"></button>
</div>
</form>
</div>
@ -78,7 +78,7 @@
</li>
<div class="clearfix"></div>
<li style="display: block;" id="bottom-of-three-btn">
<a style="display: block; padding: 7px 0; min-width: 200px">+(993) 12 60-60-60</a>
<a style="display: block; padding: 7px 0; min-width: 200px">{{\Backpack\Settings\app\Models\Setting::get('phone')}}</a>
</li>
</ul>
</div>

View File

@ -0,0 +1,3 @@
@extends('Bilettm.Layouts.BilettmLayout')
@section('content')
@endsection

View File

@ -1,6 +1,6 @@
@extends('Bilettm.Layouts.BilettmLayout')
@section('content')
@include('Bilettm.Partials.BreadCrumbs')
{{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('home')}}
<section style="margin-top: 30px; margin-bottom: 100px">
<div class="container">

11
routes/breadcrumbs.php Normal file
View File

@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: merdan
* Date: 9/11/2019
* Time: 15:07
*/
// Home
Breadcrumbs::for('home', function ($trail) {
$trail->push('Home', route('home'));
});