category filters and sorts
This commit is contained in:
parent
553aa710b1
commit
8ce6baa4b8
|
|
@ -8,6 +8,7 @@ use App\Models\Event;
|
|||
use App\Models\EventAccessCodes;
|
||||
use App\Models\EventStats;
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Cookie;
|
||||
use Illuminate\Http\Request;
|
||||
use Mail;
|
||||
|
|
@ -33,6 +34,7 @@ class EventViewController extends Controller
|
|||
}
|
||||
|
||||
$tickets = $event->tickets()->where('is_hidden', false)
|
||||
->whereDate('ticket_date','>=',Carbon::now(config('app.timezone')))
|
||||
->orderBy('sort_order', 'asc')->get();
|
||||
|
||||
$ticket_dates = array();
|
||||
|
|
|
|||
|
|
@ -44,47 +44,30 @@ class PublicController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function showEvents($cat_id = null, Request $request){
|
||||
$date = $request->get('date');
|
||||
//$cat_id = $request->get('cat_id');
|
||||
|
||||
$e_query = Event::onLive();
|
||||
$nav_query = Category::select('id','title_tk','title_ru','parent_id')
|
||||
->orderBy('lft','asc');
|
||||
$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);
|
||||
}
|
||||
else{
|
||||
$e_query->where('category_id',$category->id);
|
||||
$nav_query->where('parent_id',$category->id);
|
||||
}
|
||||
|
||||
}else{
|
||||
$nav_query->main();
|
||||
}
|
||||
|
||||
if(!empty($date)){
|
||||
$e_query->whereDate('start_date','>=',Carbon::parse($date));
|
||||
}
|
||||
|
||||
$events = $e_query->with('images')->paginate(5);
|
||||
$navigation = $nav_query->get();
|
||||
// dd($events);
|
||||
return view('Bilettm.Public.EventsPage')->with([
|
||||
'events' => $events,
|
||||
'category' => $category,
|
||||
'navigation' => $navigation
|
||||
]);
|
||||
}
|
||||
|
||||
public function showCategoryEvents($cat_id, Request $request){
|
||||
$date = $request->get('date');
|
||||
$popular = $request->get('popular');
|
||||
$sort = $request->get('sort');
|
||||
$filter =$request->get('filter');//today,tomorrow,week,month,date
|
||||
|
||||
if($sort == 'new')
|
||||
$orderBy = ['field'=>'created_at','order'=>'desc'];
|
||||
if ($sort =='pop')
|
||||
$orderBy = ['field'=>'views','order'=>'desc'];
|
||||
else
|
||||
{
|
||||
$orderBy =['field'=>'start_date','order'=>'asc'];
|
||||
$sort = 'start_date';
|
||||
}
|
||||
|
||||
switch ($filter){
|
||||
case 'today' : $date_start = Carbon::now(); $date_end = $date_start->endOfDay(); break;
|
||||
case 'tomorrow' : $date_start = Carbon::tomorrow(); $date_end = $date_start->endOfDay();break;
|
||||
case 'week' : $date_start = Carbon::now(); $date_end = $date_start->endOfWeek(); break;
|
||||
case 'month' : $date_start = Carbon::now(); $date_end = $date_start->endOfMonth(); break;
|
||||
case 'date' : $date_start = Carbon::parse($date); $date_end = $date_start->endOfDay(); break;
|
||||
default : $date_start = null; $date_end = null;
|
||||
}
|
||||
// dd(url('path'));
|
||||
// setlocale(LC_TIME, 'tk');
|
||||
// Carbon::setLocale('tk');
|
||||
// dd(Carbon::parse('2019-01-01',config('app.timezone')) ->formatLocalized('%d %B'));
|
||||
|
|
@ -92,27 +75,27 @@ class PublicController extends Controller
|
|||
$category = Category::select('id','title_tk','title_ru','view_type','events_limit','parent_id')
|
||||
->findOrFail($cat_id);
|
||||
|
||||
$data = ['sort' => $sort, 'category' => $category, 'filter' => $filter];
|
||||
|
||||
if($category->parent_id >0 || $category->view_type === 'concert'){
|
||||
$events = $category->cat_events()
|
||||
->onLive($date)
|
||||
->orderBy($popular ? 'start_date' : 'views')
|
||||
->onLive($date_start,$date_end)
|
||||
->orderBy($orderBy)
|
||||
->get();
|
||||
return view("Bilettm.EventsList.subCategoryList")->with([
|
||||
'category' => $category,
|
||||
'events' => $events
|
||||
]);
|
||||
$data['events'] = $events;
|
||||
|
||||
return view("Bilettm.Public.CategoryEventsPage")->with($data);
|
||||
}
|
||||
else{
|
||||
$subCats = $category->children()
|
||||
->withLiveEvents($date,$category->events_limit,$popular)
|
||||
->whereHas('cat_events',function ($query) use($date){
|
||||
$query->onLive($date);
|
||||
->withLiveEvents($orderBy, $date_start, $date_end, $category->events_limit)
|
||||
->whereHas('cat_events',
|
||||
function ($query) use($date_start, $date_end){
|
||||
$query->onLive($date_start, $date_end);
|
||||
})->get();
|
||||
//dd($subCats);
|
||||
return view("Bilettm.Layouts.EventsPage")->with([
|
||||
'sub_cats' => $subCats,
|
||||
'category' => $category,
|
||||
]);
|
||||
$data['sub_cats'] = $subCats;
|
||||
|
||||
return view("Bilettm.Public.EventsPage")->with($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,21 +110,15 @@ class Category extends \Illuminate\Database\Eloquent\Model{
|
|||
return $query->where('parent_id',$parent_id)->orderBy('lft','asc');
|
||||
}
|
||||
|
||||
public function scopeWithLiveEvents($query, $date = false, $popular = true){
|
||||
$limit = 8;
|
||||
return $query->with(['cat_events' => function($query) use ($date, $limit, $popular) {
|
||||
public function scopeWithLiveEvents($query, $orderBy, $start_date = null,$end_date = null, $limit = 8 ){
|
||||
return $query->with(['cat_events' => function($query) use ($start_date, $end_date, $limit, $orderBy) {
|
||||
$query->select('id','title','description','category_id','sub_category_id','start_date')
|
||||
->limit($limit)
|
||||
->with('starting_ticket')
|
||||
->withCount(['stats as views' => function($q){
|
||||
$q->select(DB::raw("SUM(views) as v"));}])
|
||||
->onLive($date);//event scope onLive get only live events
|
||||
|
||||
|
||||
if($popular)
|
||||
$query->orderBy('views','desc');
|
||||
else
|
||||
$query->orderBy('start_date');
|
||||
->onLive($start_date, $end_date)//event scope onLive get only live events
|
||||
->orderBy($orderBy['field'],$orderBy['order']);
|
||||
}]);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -476,10 +476,15 @@ ICSTemplate;
|
|||
return (is_null($this->access_codes()->where('id', $accessCodeId)->first()) === false);
|
||||
}
|
||||
|
||||
public function scopeOnLive($query, $date = null){
|
||||
public function scopeOnLive($query, $start_date = null, $end_date = null){
|
||||
//if date is null carbon creates now date instance
|
||||
return $query->whereDate('end_date','>=',Carbon::parse($date,config('app.timezone')))
|
||||
->where('is_live',1)
|
||||
if(isset($start_date) && isset($end_date))
|
||||
$query->whereDate('start_date','<=',$start_date)
|
||||
->whereDate('end_date','>=',$end_date);
|
||||
else
|
||||
$query->whereDate('end_date','>=',Carbon::now(config('app.timezone')));
|
||||
|
||||
return $query->where('is_live',1)
|
||||
->withCount(['images as image_url' => function($q){
|
||||
$q->select(DB::raw("image_path as imgurl"))
|
||||
->orderBy('created_at','desc')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
@extends('Bilettm.Layouts.BilettmLayout')
|
||||
|
||||
@section('after_styles')
|
||||
<link href="{{asset('vendor/gijgo/gijgo.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
{{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('category',$category)}}
|
||||
@include("Bilettm.Partials.FilterMenu")
|
||||
|
||||
@yield('inner_content')
|
||||
|
||||
<section id="first-add-wrapper" style="margin: 100px 0;">
|
||||
<div class="container">
|
||||
<div class="row" style="padding: 0 20px;">
|
||||
<a href="" style="width: 100%">
|
||||
<img src="{{asset('assets/images/advs/first.png')}}" style="width: 100%">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
@push('after_styles')
|
||||
<style type="text/css">
|
||||
.red_button{
|
||||
color: #ffffff;
|
||||
background-color: #d33d33;
|
||||
height: fit-content;
|
||||
font-size: 20px;
|
||||
padding: 12px 60px;
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
transition-property: background-color;
|
||||
transition-duration: .2s;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
@section('after_scripts')
|
||||
|
||||
<script src="{{asset('vendor/gijgo/gijgo.min.js')}}" type="text/javascript"></script>
|
||||
<script>
|
||||
$('#datepicker').datepicker({
|
||||
uiLibrary: 'bootstrap4',
|
||||
icons: {
|
||||
rightIcon: 'Дата <i class="fa fa-caret-down"></i>'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
@extends('Bilettm.Layouts.BilettmLayout')
|
||||
|
||||
@section('after_styles')
|
||||
<link href="{{asset('vendor/gijgo/gijgo.min.css')}}" rel="stylesheet" type="text/css" />
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
{{\DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs::render('category',$category)}}
|
||||
@include("Bilettm.Partials.FilterMenu")
|
||||
|
||||
@foreach($sub_cats as $cat)
|
||||
|
||||
<section class="movie-items-group firts-child">
|
||||
<div class="container">
|
||||
<div class="row kinoteator tab-part">
|
||||
<div class="tab-header d-flex justify-content-between col-12">
|
||||
<h2 class="font-weight-bold">{{$cat->title}}</h2>
|
||||
<div style="height: 5px; position: absolute; bottom: 0px; width: 100px; background-color: rgba(211,61,51,1)"></div>
|
||||
<a class="red_button" href="{{$cat->url}}">Весь репертуар</a>
|
||||
</div>
|
||||
<div class="tab-ozi col-12" style="margin-top: 10px">
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@foreach($cat->cat_events as $event)
|
||||
@include("Bilettm.EventsList.{$category->view_type}",['event'=>$event])
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Tab panes -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@endforeach
|
||||
<section id="first-add-wrapper" style="margin: 100px 0;">
|
||||
<div class="container">
|
||||
<div class="row" style="padding: 0 20px;">
|
||||
<a href="" style="width: 100%">
|
||||
<img src="{{asset('assets/images/advs/first.png')}}" style="width: 100%">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
@push('after_styles')
|
||||
<style type="text/css">
|
||||
.red_button{
|
||||
color: #ffffff;
|
||||
background-color: #d33d33;
|
||||
height: fit-content;
|
||||
font-size: 20px;
|
||||
padding: 12px 60px;
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
transition-property: background-color;
|
||||
transition-duration: .2s;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
@section('after_scripts')
|
||||
|
||||
<script src="{{asset('vendor/gijgo/gijgo.min.js')}}" type="text/javascript"></script>
|
||||
<script>
|
||||
$('#datepicker').datepicker({
|
||||
uiLibrary: 'bootstrap4',
|
||||
icons: {
|
||||
rightIcon: 'Дата <i class="fa fa-caret-down"></i>'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
@ -1,25 +1,27 @@
|
|||
<nav>
|
||||
<div class="container">
|
||||
<ul class="nav u-nav-v1-1 g-mb-20 category-filter" role="tablist" data-target="nav-1-1-default-hor-left" data-tabs-mobile-type="slide-up-down" data-btn-classes="btn btn-md btn-block rounded-0 u-btn-outline-lightgray g-mb-20">
|
||||
<ul class="nav u-nav-v1-1 g-mb-20 category-filter" data-btn-classes="btn btn-md btn-block rounded-0 u-btn-outline-lightgray g-mb-20">
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="" role="tab">Популярное</a>
|
||||
<a class="nav-link active" href="{{$category->url}}?sort=pop&filter={{$filter}}">Популярное</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab">Новые</a>
|
||||
<a class="nav-link" href="{{$category->url}}?sort=new&filter={{$filter}}">Новые</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="tab">Сегодня <i class="fa fa-caret-down"></i></a>
|
||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="tab">Filter <i class="fa fa-caret-down"></i></a>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item nav-link" data-toggle="tab" href="" role="tab">SLink 1</a>
|
||||
<a class="dropdown-item nav-link" data-toggle="tab" href="" role="tab">SLink 2</a>
|
||||
<a class="dropdown-item nav-link" data-toggle="tab" href="" role="tab">SLink 3</a>
|
||||
<a class="dropdown-item nav-link" href="{{$category->url}}?sort={{$sort}}&filter=today" >Today</a>
|
||||
<a class="dropdown-item nav-link" href="{{$category->url}}?sort={{$sort}}&filter=tomorrow" >Tomorrow</a>
|
||||
<a class="dropdown-item nav-link" href="{{$category->url}}?sort={{$sort}}&filter=week" >This week</a>
|
||||
<a class="dropdown-item nav-link" href="{{$category->url}}?sort={{$sort}}&filter=month" >This month</a>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown" style="position: relative; margin-left: -20px;">
|
||||
<form action="" class="calendar-form">
|
||||
<form action="{{$category->url}}" method="post" class="calendar-form">
|
||||
@csrf
|
||||
{{--<a class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="tab">Дата <i class="fa fa-caret-down"></i></a>--}}
|
||||
<input id="datepicker" placeholder="Select date" />
|
||||
<input id="datepicker" placeholder="Select date" name="date"/>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
@extends("Bilettm.Layouts.EventsLayout")
|
||||
@section('inner_content')
|
||||
<section class="movie-items-group">
|
||||
<div class="container">
|
||||
<div class="row kinoteator tab-part">
|
||||
<div class="tab-header d-flex justify-content-between col-12">
|
||||
<h2>{{$category->title}}</h2>
|
||||
<div style="height: 5px; position: absolute; bottom: 0px; width: 100px; background-color: rgba(211,61,51,1)"></div>
|
||||
</div>
|
||||
<div class="tab-ozi col-12">
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@foreach($events as $event)
|
||||
@include("Bilettm.EventsList.{$category->view_type}")
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Tab panes -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
@extends("Bilettm.Layouts.EventsLayout")
|
||||
@section('inner_content')
|
||||
@foreach($sub_cats as $cat)
|
||||
|
||||
<section class="movie-items-group firts-child">
|
||||
<div class="container">
|
||||
<div class="row kinoteator tab-part">
|
||||
<div class="tab-header d-flex justify-content-between col-12">
|
||||
<h2 class="font-weight-bold">{{$cat->title}}</h2>
|
||||
<div style="height: 5px; position: absolute; bottom: 0px; width: 100px; background-color: rgba(211,61,51,1)"></div>
|
||||
<a class="red_button" href="{{$cat->url}}">Весь репертуар</a>
|
||||
</div>
|
||||
<div class="tab-ozi col-12" style="margin-top: 10px">
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
@foreach($cat->cat_events as $event)
|
||||
@include("Bilettm.EventsList.{$category->view_type}",['event'=>$event])
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Tab panes -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@endforeach
|
||||
|
||||
@endsection
|
||||
Loading…
Reference in New Issue