1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Http\Controllers;
7
8use App\Models\Contest;
9use Carbon\Carbon;
10use stdClass;
11
12class SeasonalBackgroundsController extends Controller
13{
14 public function index()
15 {
16 $contest = Contest::find($GLOBALS['cfg']['osu']['seasonal']['contest_id']);
17
18 if ($contest === null) {
19 return response()->json(new stdClass());
20 }
21
22 $backgrounds = $contest->userContestEntries()->where('show_in_client', true)->get();
23
24 return [
25 'ends_at' => json_time(Carbon::parse($GLOBALS['cfg']['osu']['seasonal']['ends_at'])),
26
27 'backgrounds' => json_collection($backgrounds, 'SeasonalBackground'),
28 ];
29 }
30}