where('slug', $slug) ->where('published', true) ->with([ 'formSchema', 'tracks' => function ($q) { $q->where('is_enabled', true)->orderBy('sort')->orderBy('id'); }, ]) ->firstOrFail(); return response()->json([ 'id' => $competition->id, 'slug' => $competition->slug, 'name' => $competition->name, 'description' => $competition->description, 'pledge_content_html' => $competition->pledge_content_html, 'status' => $competition->status, 'signup_open_at' => $competition->signup_open_at?->toIso8601String(), 'signup_close_at' => $competition->signup_close_at?->toIso8601String(), 'branding_json' => $competition->branding_json ?? new \stdClass, 'signup_form_schema' => $competition->formSchema?->schema_json ?? [], 'tracks' => $competition->tracks->map(fn ($t) => [ 'track_code' => $t->track_code, 'title' => $t->title, 'description' => $t->description, 'sort' => $t->sort, ]), ]); } }