eventflow / app /Http /Controllers /HomeController.php
Ezekiel999's picture
Fix SQLite compatibility: replace HAVING with whereHas in HomeController
7221501 verified
<?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'));
}
}