diff --git a/site_novo/app/Http/Controllers/EventController.php b/site_novo/app/Http/Controllers/EventController.php index f9ff3dd..fc3ca52 100644 --- a/site_novo/app/Http/Controllers/EventController.php +++ b/site_novo/app/Http/Controllers/EventController.php @@ -8,8 +8,8 @@ class EventController extends Controller { public function index() { - $events = Event::published()->upcoming()->orderBy('starts_at')->get(); + $upcomingEvents = Event::published()->upcoming()->orderBy('starts_at')->get(); - return view('events.index', ['events' => $events]); + return view('events.index', ['upcomingEvents' => $upcomingEvents]); } } diff --git a/site_novo/app/Livewire/Events/EventList.php b/site_novo/app/Livewire/Events/EventList.php new file mode 100644 index 0000000..361dba7 --- /dev/null +++ b/site_novo/app/Livewire/Events/EventList.php @@ -0,0 +1,45 @@ + ['except' => 'all'], + ]; + + public function mount(): void + { + $this->loadEvents(); + } + + public function updatedFilter(): void + { + $this->loadEvents(); + } + + private function loadEvents(): void + { + $query = Event::published(); + + match ($this->filter) { + 'upcoming' => $query->upcoming()->orderBy('starts_at'), + 'past' => $query->past()->orderBy('starts_at', 'desc'), + default => $query->orderBy('starts_at', 'desc'), + }; + + $this->events = $query->get(); + } + + public function render() + { + return view('livewire.events.event-list'); + } +} diff --git a/site_novo/app/Models/Event.php b/site_novo/app/Models/Event.php index 0f7fedd..38d43b9 100644 --- a/site_novo/app/Models/Event.php +++ b/site_novo/app/Models/Event.php @@ -53,6 +53,15 @@ public function scopeUpcoming(Builder $query): Builder return $query->where('starts_at', '>=', now()); } + /** + * @param Builder $query + * @return Builder + */ + public function scopePast(Builder $query): Builder + { + return $query->where('starts_at', '<', now()); + } + public function getBanner(): ?string { if ($this->banner) { diff --git a/site_novo/resources/views/components/landing/event-card.blade.php b/site_novo/resources/views/components/landing/event-card.blade.php new file mode 100644 index 0000000..a2a9847 --- /dev/null +++ b/site_novo/resources/views/components/landing/event-card.blade.php @@ -0,0 +1,26 @@ +@props(['event', 'index' => 0]) + +@php $isPast = $event->starts_at->isPast(); @endphp + +
merge(['class' => 'relative snap-start rounded-[10px] overflow-hidden bg-[#0c3a68] border border-white/[0.08] transition-transform hover:-translate-y-1']) }}> + @if ($isPast) +
+ ENCERRADO +
+ @endif +
$isPast, + 'bg-[radial-gradient(circle_at_30%_40%,#3a6a9c,#0a2a4a_70%)]' => $index % 4 === 0, + 'bg-[radial-gradient(circle_at_70%_30%,#4b7aa6,#0a2a4a_70%)]' => $index % 4 === 1, + 'bg-[radial-gradient(circle_at_50%_60%,#2f5f94,#07223f_70%)]' => $index % 4 === 2, + 'bg-[radial-gradient(circle_at_20%_70%,#3f6e9e,#08254a_70%)]' => $index % 4 === 3, + ]) @style([ + "background-image: url('{$event->getBanner()}')" => $event->getBanner(), + ])>
+
+

{{ $event->title }}

+ {{ $event->location }} + +
+
diff --git "a/site_novo/resources/views/components/landing/\342\232\241events-timeline.blade.php" "b/site_novo/resources/views/components/landing/\342\232\241events-timeline.blade.php" index bd70896..7409466 100644 --- "a/site_novo/resources/views/components/landing/\342\232\241events-timeline.blade.php" +++ "b/site_novo/resources/views/components/landing/\342\232\241events-timeline.blade.php" @@ -8,7 +8,11 @@ public function mount(): void { - $this->events = Event::published()->orderBy('starts_at', 'desc')->take(8)->get(); + $this->events = Event::published()->upcoming()->orderBy('starts_at')->take(8)->get(); + + if ($this->events->isEmpty()) { + $this->events = Event::published()->past()->orderBy('starts_at', 'desc')->take(8)->get(); + } } }; ?> @@ -29,7 +33,16 @@ class="w-full sm:w-auto justify-center inline-flex items-center gap-2.5 px-[18px - @if (count($events) > 0) + @if (count($events) === 0) +

Nenhum evento publicado no momento. Volte em breve!

+ @elseif (count($events) <= 4) + {{-- Poucos eventos: grade simples, sem carrossel (evita cards soltos e setas sem função) --}} +
+ @foreach ($events as $i => $event) + + @endforeach +
+ @else @@ -69,8 +67,6 @@ class="hidden sm:grid place-items-center absolute top-[40%] -right-[18px] z-[5] - @else -

Nenhum evento publicado no momento. Volte em breve!

@endif diff --git a/site_novo/resources/views/events/index.blade.php b/site_novo/resources/views/events/index.blade.php index 9861aeb..a3a5e5b 100644 --- a/site_novo/resources/views/events/index.blade.php +++ b/site_novo/resources/views/events/index.blade.php @@ -1,12 +1,12 @@ - @if ($events->count() > 0) + @if ($upcomingEvents->count() > 0)