File size: 735 Bytes
10dc6f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7221501
10dc6f2
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace App\Http\Controllers;

use App\Models\Category;
use App\Models\Event;

class HomeController extends Controller
{
    public function index()
    {
        $featuredEvents = Event::with('category', 'ticketTiers', 'organizer')
            ->published()
            ->where('start_at', '>=', now())
            ->orderBy('start_at')
            ->take(6)
            ->get();

        $categories = Category::withCount(['events' => fn($q) => $q->published()])
            ->whereHas('events', fn($q) => $q->published())
            ->orderBy('name')
            ->get();

        $totalEvents = Event::published()->count();

        return view('welcome', compact('featuredEvents', 'categories', 'totalEvents'));
    }
}