use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
class EpisodeController extends Controller
{
'event' => 'nullable|array',
'event.*' => 'numeric',
]);
- $after = isset($validatedData['after']) ? $validatedData['after'] : Carbon::now()->sub(2, 'hours');
+ $after = isset($validatedData['after']) ? $validatedData['after'] : Carbon::now();
$before = isset($validatedData['before']) ? $validatedData['before'] : Carbon::now()->add(1, 'days');
$episodes = Episode::with(['channels', 'event', 'players', 'players.user'])
->select('episodes.*')
->join('events', 'episodes.event_id', '=', 'events.id')
->where('episodes.confirmed', '=', true)
- ->where('episodes.start', '>=', $after)
+ ->where(DB::raw('DATE_ADD(`episodes`.`start`, INTERVAL COALESCE(`episodes`.`estimate`, 0) SECOND)'), '>=', $after)
->where('episodes.start', '<=', $before)
->where('events.visible', '=', true)
->orderBy('episodes.start')
axios.get(`/api/episodes`, {
signal: controller.signal,
params: {
- after: moment().subtract(8, 'hours').subtract(behind, 'days').toISOString(),
+ after: moment().subtract(2, 'hours').subtract(behind, 'days').toISOString(),
before: moment().add(16, 'hours').add(ahead, 'days').toISOString(),
...filter,
},