feat: Add functions to retrieve previous and upcoming events; update events template to display dynamic event data

This commit is contained in:
2025-08-22 11:15:13 +05:45
parent 711ae9caf9
commit 31bea937c4
3 changed files with 61 additions and 189 deletions

View File

@@ -4,6 +4,7 @@ use Modules\CCMS\Models\Blog;
use Modules\CCMS\Models\Category;
use Modules\CCMS\Models\Counter;
use Modules\CCMS\Models\Country;
use Modules\CCMS\Models\Event;
use Modules\CCMS\Models\Faq;
use Modules\CCMS\Models\FaqCategory;
use Modules\CCMS\Models\Gallery;
@@ -150,6 +151,32 @@ function getServices($limit = null, $order = 'desc')
->get();
}
function previousEvents($limit = null, $order = 'desc')
{
return Event::query()
->where('status', 1)
->where('parent_id', null)
->where('start_date', '<=', now())
->orderBy('order', $order)
->when($limit, function ($query) use ($limit) {
$query->limit($limit);
})
->get();
}
function upcomingEvents($limit = null, $order = 'desc')
{
return Event::query()
->where('status', 1)
->where('parent_id', null)
->where('start_date', '>=', now())
->orderBy('order', $order)
->when($limit, function ($query) use ($limit) {
$query->limit($limit);
})
->get();
}
function getInstitutions($limit = null, $order = 'desc')
{
return Institution::query()

View File

@@ -52,6 +52,8 @@ class WebsiteController extends Controller
$data['successGalleries'] = getGalleriesByCategory(limit: 3, order: 'asc', category: 'voice-of-success');
$data['destinations'] = getDestinations(limit: null, order: 'asc');
$data['services'] = getServices(limit: null, order: 'asc');
$data['previousEvents'] = previousEvents(limit: null, order: 'asc');
$data['upcomingEvents'] = upcomingEvents(limit: null, order: 'asc');
$data['classes'] = getClasses(limit: null, order: 'asc');
$data['institutions'] = getInstitutions(limit: null, order: 'asc');
$data['faqs'] = getFAQs(limit: null, order: 'desc');

View File

@@ -22,101 +22,25 @@
<div class="swiper swiper-events mt-40 mb-40">
<div class="swiper-wrapper">
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
@foreach ($upcomingEvents as $event)
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset($event->image) }}" alt="">
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Start</h4>
<h4 class="text-18 font-bold text-black">{{ $event->start_date }}</h4>
</div>
<div>
<h3 class="text-16 text-black">{{ $event->title }}</h3>
<p class="text-14 p-0 m-0 text-grey">{{ $event->short_description }} </p>
</div>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
</a>
@endforeach
</div>
<!-- Pagination -->
<!-- <div class="swiper-pagination"></div> -->
@@ -137,102 +61,27 @@
<div class="swiper swiper-events mt-40">
<div class="swiper-wrapper">
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
@foreach ($upcomingEvents as $event)
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset($event->image) }}" alt="">
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Start</h4>
<h4 class="text-18 font-bold text-black">{{ $event->start_date }}</h4>
</div>
<div>
<h3 class="text-16 text-black">{{ $event->title }}</h3>
<p class="text-14 p-0 m-0 text-grey">{{ $event->short_description }} </p>
</div>
</div>
</div>
</div>
</a>
</a>
@endforeach
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
<a href="" class="swiper-slide">
<div class="event-block relative w-full">
<div class="w-full rounded-30">
<img src="{{ asset('raffles/assets/images/general/event1.jfif') }}" alt="">
</div>
<div class="flex items-center gap-20 py-20 px-20 bg-white rounded-30">
<div>
<h4 class="text-16 text-ter">Apr</h4>
<h4 class="text-18 font-bold text-black">14</h4>
</div>
<div>
<h3 class="text-16 text-black">Free ilets Class: Raffles Educare Associates</h3>
<p class="text-14 p-0 m-0 text-grey">Join the free ilets Classes </p>
<p class="text-14 text-grey">Starting from 5 pm - 7 pm </p>
</div>
</div>
</div>
</a>
</div>
<!-- Pagination -->
<!-- <div class="swiper-pagination"></div> -->
@@ -280,12 +129,6 @@
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
{{-- <div class="flex justify-center items-center ">
<button class="text-center bg-white text-ter rounded-30 text-14">Load More</button>
</div> --}}
</div>
@endsection