breadcrumbs fix

This commit is contained in:
merdiano 2019-09-16 18:30:51 +05:00
parent 8b7a26274d
commit 83006ebb2d
4 changed files with 16 additions and 10 deletions

View File

@ -54,16 +54,13 @@ class PublicController extends Controller
$e_query = Event::onLive();
$nav_query = Category::select('id','title_tm','title_ru','parent_id')
->orderBy('lft','asc');
$active_id = -1;
$category = null;
if(!empty($cat_id)){
$category = Category::findOrFail($cat_id);
if($category->parent_id > 0){
$e_query->where('sub_category_id',$category->id);
$nav_query->where('parent_id',$category->parent_id);
$active_id = $category->id;
}
else{
$e_query->where('category_id',$category->id);
@ -78,12 +75,12 @@ class PublicController extends Controller
$e_query->whereDate('start_date','>=',Carbon::parse($date));
}
$events = $e_query->paginate(20);
$events = $e_query->paginate(10);
$navigation = $nav_query->get();
dd($events);
return view('Bilettm.Public.EventsPage')->with([
'events' => $events,
'active_id' => $active_id,
'category' => $category,
'navigation' => $navigation
]);
}

View File

@ -68,4 +68,8 @@ class Category extends \Illuminate\Database\Eloquent\Model{
public function getChildren($parent_id){
return $this->where('parent_id',$parent_id)->orderBy('lft','asc');
}
public function parent(){
return $this->belongsTo(Category::class,'parent_id');
}
}

View File

@ -1,6 +1,6 @@
@extends('Bilettm.Layouts.BilettmLayout')
@section('content')
{{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('category',$category??null)}}
{{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('category',$category)}}
<!-- Films Opisanie Buttons section -->
<section id='cat_and_buttons'>
<div class="container">

View File

@ -10,9 +10,14 @@ Breadcrumbs::for('home', function ($trail) {
$trail->push('Home', route('home'));
});
Breadcrumbs::for('category', function ($trail,$category){
Breadcrumbs::for('category', function ($trail, $category){
$trail->parent('home');
$trail->push($category->name ?? "Events", $category->url ?? '#');
if(!empty($category) && $category->parent_id){
$parent = $category->parent;
$trail->push($parent->title,$parent->url);
}
$trail->push($category->title ?? 'Events', $category->url ?? '#');
});
Breadcrumbs::for('event',function($trail, $event){