<?php

namespace Zeropingheroes\Lanager\Http\Controllers\Api;

use Illuminate\Http\Request;
use Zeropingheroes\Lanager\Http\Controllers\Controller;
use Zeropingheroes\Lanager\Http\Resources\Event as EventResource;
use Zeropingheroes\Lanager\Event;

class EventController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param Request $request
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     */
    public function index(Request $request)
    {
        $events = Event::where('published', 1);

        if ($request->filled('after')) {
            $events->where('start', '>', $request->after);
            $events->orWhere('end', '>', $request->after);
        }

        if ($request->filled('limit')) {
            $events->limit($request->limit);
        }

        $events = $events->orderBy('start')->get();

        return EventResource::collection($events);
    }

    /**
     * Display the specified resource.
     *
     * @param  \Zeropingheroes\Lanager\Event $event
     * @return EventResource
     */
    public function show(Event $event)
    {
        $event->load('lan');
        return new EventResource($event);
    }
}

<?php

namespace Zeropingheroes\Lanager\Http\Controllers\Api;

use Illuminate\Http\Request;
use Zeropingheroes\Lanager\Http\Controllers\Controller;
use Zeropingheroes\Lanager\Http\Resources\Event as EventResource;
use Zeropingheroes\Lanager\Event;

class EventController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @param Request $request
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
     */
    public function index(Request $request)
    {
        $events = Event::where('published', true);

        if ($request->filled('after')) {
            $events->where(function ($query) use ($request) {
                $query->where('start', '>', $request->after)
                      ->orWhere('end', '>', $request->after);
            });
        }

        if ($request->filled('limit')) {
            $events->limit($request->limit);
        }

        $events = $events->orderBy('start')->get();

        return EventResource::collection($events);
    }

    /**
     * Display the specified resource.
     *
     * @param  \Zeropingheroes\Lanager\Event $event
     * @return EventResource
     */
    public function show(Event $event)
    {
        $event->load('lan');
        return new EventResource($event);
    }
}

Fix unpublished events showing when querying for events after a given time
Fix unpublished events showing when querying for events after a given time
