Reporting - Tournament Reporting
This section covers tournament reporting, powered by the TournamentReport class. It provides a high-level overview of all current-season tournaments, grouped by website, with metrics on team counts and payment status, and links to drill-down into individual event details.
📁 App\Reports\TournamentReport
Located at app/Reports/TournamentReport.php, this class encapsulates all tournament-related report logic. It keeps report generation separate from controllers and views.
Dependencies
- Models:
Website,Event - Utilities:
Carbon\Carbonfor date formatting,route()helper for links - Blade view:
dashboard.reports.graphs.tournamentoverview
Method: eventOverview()
The eventOverview() method is the primary entry point for the tournament overview report.
- Fetches the selected Website based on the
websitequery parameter. - If no website is selected, renders a grid of all site logos for selection.
- Retrieves all tournament-type events in the current season for that site, excluding cancelled events.
- Eager loads
teamsandvenuesrelationships. - Calculates per-event metrics:
- Total teams
- Paid teams (
pivot.is_paid = 1) - Unpaid teams (
pivot.is_paid = 0)
- Aggregates site totals.
- Returns the
tournamentoverviewBlade view withreport_nameanddata.
public function eventOverview(): View
{
$data = [];
$website = Website::find(request()->get('website'));
// No website selected → show site selector
if (! $website) {
return view('dashboard.reports.graphs.tournamentoverview', [
'report_name' => 'Event Overview',
'data' => $data,
]);
}
$total = $paid = $unpaid = 0;
$events = Event::currentSeason()
->where('type', 'tournament')
->where('website_id', $website->id)
->where('internal_status', '!=', 'Cancelled')
->with(['teams', 'venues'])
->orderBy('start_date', 'ASC')
->get();
foreach ($events as $event) {
$teamCount = $event->teams->count();
$paidCount = $event->teams->where('pivot.is_paid', 1)->count();
$unpaidCount = $event->teams->where('pivot.is_paid', 0)->count();
$data[$website->name]['events'][] = [
'event' => [
'title' => $event->title,
'logo' => $event->logo,
'start_date' => Carbon::parse($event->start_date)->format('m-d-Y'),
'url' => route('events.show', $event),
],
'team_count' => $teamCount,
'paid_teams' => $paidCount,
'unpaid_teams'=> $unpaidCount,
];
$total += $teamCount;
$paid += $paidCount;
$unpaid += $unpaidCount;
}
$data[$website->name]['current_season'] = $website->current_season;
$data[$website->name]['team_totals']['total']= $total;
$data[$website->name]['team_totals']['paid'] = $paid;
$data[$website->name]['team_totals']['unpaid']= $unpaid;
return view('dashboard.reports.graphs.tournamentoverview', [
'report_name' => 'Tournament Overview',
'data' => $data,
]);
}
Route Configuration
Tournament reports are accessible under the /report/{type}/{name} pattern. Specifically:
// routes/reports.php
Route::middleware('auth')->group(function () {
Route::middleware('role:Admin|Event Manager')->group(function () {
// Main report loader
Route::get('/report/{type}/{name}', [ReportController::class, 'loadReport'])
->name('loadReport');
});
});
When you visit /report/tournament/eventoverview, Laravel invokes:
ReportController::loadReport('tournament','eventoverview')- Which calls
App\Reports\TournamentReport::eventOverview()
View: tournamentoverview.blade.php
Located at resources/views/dashboard/reports/graphs/tournamentoverview.blade.php, this Blade template handles both site selection and metrics display.
{{-- Site selector --}}
@if (! $website)
<h4>{{ $report_name }}</h4>
<div class="grid grid-cols-1 lg:grid-cols-4 gap-4 py-3">
@foreach (App\Models\Website::all() as $site)
<a href="?website={{ $site->id }}">
<x-block class="py-3 border">
<img src="{{ $site->logo }}" style="height:40px;" class="mb-3 mx-auto">
<h4 class="text-center font-semibold">{{ $site->name }}</h4>
</x-block>
</a>
@endforeach
</div>
@else
{{-- Metrics summary --}}
<div class="flex flex-wrap mb-4">
@foreach (['total'=>'Total Teams','paid'=>'Paid Teams','unpaid'=>'Unpaid Teams'] as $key => $label)
<div class="w-1/3 p-2 text-center">
<div class="text-3xl font-semibold {{ $key=='paid'?'text-success':'' }} {{ $key=='unpaid'?'text-danger':'' }}">
{{ $data[$website->name]['team_totals'][$key] }}
</div>
<p class="font-medium">{{ $label }}</p>
</div>
@endforeach
</div>
{{-- Event table --}}
<x-table bordered>
<x-slot name="headers">
<th>Event</th><th>Teams</th><th>Paid</th><th>Unpaid</th>
</x-slot>
<x-slot name="rows">
@forelse ($data[$website->name]['events'] as $ed)
<tr>
<td>
<a href="{{ $ed['event']['url'] }}">
<h5 class="font-bold">{{ $ed['event']['title'] }}</h5>
<span class="text-sm text-muted">{{ $ed['event']['start_date'] }}</span>
</a>
</td>
<td>{{ $ed['team_count'] }}</td>
<td>{{ $ed['paid_teams'] }}</td>
<td>{{ $ed['unpaid_teams'] }}</td>
</tr>
@empty
<tr><td colspan="4">No events found.</td></tr>
@endforelse
</x-slot>
</x-table>
@endif
Sequence Diagram
flowchart TD
A[User requests /report/tournament/eventoverview] --> B[ReportController.loadReport]
B --> C[TournamentReport.eventOverview()]
C -->|fetch| D[Website::find & Event::currentSeason()]
D -->|compute| E[Aggregate team counts]
E -->|render| F[Blade: tournamentoverview.blade.php]
Highlight
{
"title": "Key Point",
"content": "All events use the currentSeason scope on the Event model."
}
What’s Next?
- Drill-Down: Clicking an event title navigates to the event’s detail page for deeper inspection.
- Extendability: Add filters or export options by enhancing
eventOverview()or creating new report methods inTournamentReport.