@php
/** @var \App\Models\CharityAnalysis $analysis */
$report = $analysis->report ?? [];
$sources = collect($analysis->sources ?? [])->keyBy('id');
$confColors = ['high' => '#15803d', 'medium' => '#d97706', 'low' => '#b91c1c'];
// How a citation is shown depends on whether the quote was found in text
// we hold — not on who found the page. See Services\Ai\CitationVerifier.
$statuses = [
'verified' => [
'color' => '#15803d',
'label' => 'Quote found in the source',
],
'quote_not_found' => [
'color' => '#b91c1c',
'label' => 'Quote NOT found in this source — treat as unsupported',
],
'no_quote' => [
'color' => '#6b7280',
'label' => 'Source held, but nothing was quoted to check',
],
'unreadable' => [
'color' => '#d97706',
'label' => 'Link only — we could not fetch or read this source',
],
];
$statusOf = fn (array $item) => $statuses[$item['status'] ?? ($item['verified'] ?? false ? 'verified' : 'unreadable')]
?? $statuses['unreadable'];
$scoreColor = function (?float $score): string {
if ($score === null) return '#6b7280';
return $score >= 66 ? '#15803d' : ($score >= 33 ? '#d97706' : '#b91c1c');
};
$metrics = [
'r1_revenue' => ['title' => 'R1 — Revenue', 'weight' => '50% of composite'],
'r2_religious' => ['title' => 'R2 — Religious', 'weight' => '20% of composite'],
'r3_recipient' => ['title' => 'R3 — Recipient', 'weight' => '15% of composite'],
'r4_results' => ['title' => 'R4 — Results', 'weight' => '15% of composite'],
];
@endphp
{{-- ── Run header ─────────────────────────────────────────────────────── --}}
{{ $analysis->provider_label }}{{ $analysis->model ? ' · ' . $analysis->model : '' }}
{{ $analysis->website_url }}
@if ($analysis->finished_at)
Run {{ $analysis->finished_at->diffForHumans() }}
@endif
@if ($analysis->applied_at)
Applied {{ $analysis->applied_at->format('M j, Y') }}
@endif
@php $verification = $report['verification'] ?? null; @endphp
@if ($verification)
@php $counts = $verification['counts'] ?? []; @endphp
Citations checked:
{{ $counts['verified'] ?? 0 }} verified
@if (($counts['quote_not_found'] ?? 0) > 0)
{{ $counts['quote_not_found'] }} quote not found
@endif
@if (($counts['no_quote'] ?? 0) > 0)
{{ $counts['no_quote'] }} unquoted
@endif
@if (($counts['unreadable'] ?? 0) > 0)
{{ $counts['unreadable'] }} link only
@endif
{{ $verification['external_fetches'] ?? 0 }} source(s) fetched after the run
@unless ($verification['pdf_reader'] ?? true)
· PDF text extraction unavailable on this server
@endunless
@endif
@if ($analysis->status !== 'completed')
{{ $analysis->status === 'failed' ? 'This run failed' : 'This run is still going' }}
{{ $analysis->error ?: $analysis->progress_message }}
@if (filled($analysis->raw_response))
Model reply (unparsed)
{{ mb_substr($analysis->raw_response, 0, 20000) }}
@endif
@endif
@if ($report)
{{-- ── Composite + metric pills ───────────────────────────────────── --}}
{{ $report['suggested_composite'] !== null ? number_format((float) $report['suggested_composite'], 1) : 'N/A' }}
Suggested composite
@foreach ($metrics as $key => $meta)
@php
$metric = $report['metrics'][$key] ?? null;
$score = $metric['score'] ?? null;
@endphp
{{ $meta['title'] }}
{{ $score === null ? 'N/A' : number_format((float) $score, 1) }}
@endforeach
@if (filled($report['summary'] ?? null))
{{ $report['summary'] }}
@endif
@if (($report['organisation_identified']['matches_record'] ?? true) === false)
The site may not be this charity.
{{ $report['organisation_identified']['note'] ?? '' }}
@endif
{{-- ── One card per metric ────────────────────────────────────────── --}}
@foreach ($metrics as $key => $meta)
@php $metric = $report['metrics'][$key] ?? null; @endphp
@continue (! $metric)
{{ $meta['title'] }}
{{ $meta['weight'] }}
{{ $metric['score'] === null ? 'N/A' : number_format((float) $metric['score'], 1) }}
{{ strtoupper($metric['confidence'] ?? 'low') }} CONFIDENCE
@if ($key === 'r2_religious')
Identity {{ $metric['identity_score'] === null ? '—' : number_format((float) $metric['identity_score'], 1) }} / 50
Integrity {{ $metric['integrity_score'] === null ? '—' : number_format((float) $metric['integrity_score'], 1) }} / 50
@endif
@if (filled($metric['reasoning'] ?? null))
{{ $metric['reasoning'] }}
@endif
{{-- The arithmetic the score came out of, for the three
metrics the methodology gives an arithmetic for. --}}
@if (! empty($metric['calculation']))
@include('filament.charities.ai-ledger', [
'key' => $key,
'ledger' => $metric['calculation'],
'claimed' => $metric['score_claimed'] ?? null,
'sources' => $sources,
])
@endif
@if (! empty($metric['evidence']))
Evidence
@foreach ($metric['evidence'] as $item)
@php $status = $statusOf($item); @endphp
{{ $item['claim'] }}
@if (filled($item['quote'] ?? null))
“{{ $item['quote'] }}”
@endif
@endforeach
@endif
@if (! empty($metric['inferences']))
Inference (not directly evidenced)
@foreach ($metric['inferences'] as $inference)
{{ $inference['statement'] }}
@if (filled($inference['basis'] ?? null))
Basis: {{ $inference['basis'] }}
@endif
@endforeach
@endif
@if (! empty($metric['unverified_claims']))
Claims with no usable citation — treat as unsupported
@foreach ($metric['unverified_claims'] as $claim)
- {{ $claim }}
@endforeach
@endif
@if (! empty($metric['missing_information']))
Not published / not found:
{{ implode('; ', $metric['missing_information']) }}
@endif
@endforeach
{{-- ── Documents, flags, gaps ─────────────────────────────────────── --}}
@if (! empty($report['documents_found']))
Documents found
@foreach ($report['documents_found'] as $document)
-
{{ $document['label'] }}
@if (filled($document['kind'] ?? null))
— {{ $document['kind'] }}
@endif
@endforeach
@endif
@if (! empty($report['red_flags']))
@endif
@if (! empty($report['missing_information']))
What the site does not publish
@foreach ($report['missing_information'] as $gap)
- {{ $gap }}
@endforeach
@endif
@if (filled($report['notes_for_reviewer'] ?? null))
Notes for the reviewer
{{ $report['notes_for_reviewer'] }}
@endif
{{-- ── Provenance ─────────────────────────────────────────────────── --}}
Sources read ({{ $sources->count() }})
@foreach ($sources as $source)
{{ $source['id'] }} |
{{ $source['title'] ?: $source['url'] }}
@if ($source['kind'] === 'document')
{{ ($source['chars'] ?? 0) > 0 ? 'DOCUMENT — TEXT EXTRACTED' : 'DOCUMENT — COULD NOT BE READ' }}
@endif
|
{{ $source['topic'] ?: '—' }} |
{{ ($source['origin'] ?? 'crawled') === 'model' ? 'The model' : 'Crawler' }} |
@endforeach
@if (! empty($report['provider_citations']))
Pages the model fetched itself ({{ count($report['provider_citations']) }})
@foreach ($report['provider_citations'] as $url)
- {{ $url }}
@endforeach
@endif
@if (! empty($report['crawler_notes']))
Crawler notes
@foreach ($report['crawler_notes'] as $note)
- {{ $note }}
@endforeach
@endif
Suggested scores only. Nothing here changes a charity until you use “Apply scores”, where every number stays editable.
@endif