From 6e6be7d7c618ac23bc8d6c134f2cc39395b565de Mon Sep 17 00:00:00 2001 From: m105 Date: Wed, 22 Jul 2026 21:36:19 +0300 Subject: [PATCH] Add backlinks section to the site detail page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Shows inbound links (who links to this site, via Site::inboundLinks()) with the referring site, source page, and anchor text — paginated separately from the Pages table via a distinct page-name query param so both can paginate independently. Also surfaces a simple outbound link count and a "N backlinks from M referring domains" summary. Verified against real data: crawled podcastyradio.es (previously only known as a backlink target from 00podcast.es) and confirmed its detail page correctly shows that inbound link with the right anchor text. --- app/Http/Controllers/SiteController.php | 18 ++++++++- resources/views/sites/show.blade.php | 52 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 93d51cc..683038c 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -9,8 +9,22 @@ class SiteController extends Controller { public function show(Site $site): View { - $pages = $site->pages()->orderBy('url')->paginate(50); + $pages = $site->pages()->orderBy('url')->paginate(50, ['*'], 'pages_page'); - return view('sites.show', ['site' => $site, 'pages' => $pages]); + $backlinks = $site->inboundLinks() + ->with(['site', 'sitePage']) + ->latest() + ->paginate(50, ['*'], 'backlinks_page'); + + $referringDomainsCount = $site->inboundLinks()->distinct()->count('site_id'); + $outboundLinksCount = $site->outboundLinks()->count(); + + return view('sites.show', [ + 'site' => $site, + 'pages' => $pages, + 'backlinks' => $backlinks, + 'referringDomainsCount' => $referringDomainsCount, + 'outboundLinksCount' => $outboundLinksCount, + ]); } } diff --git a/resources/views/sites/show.blade.php b/resources/views/sites/show.blade.php index 17a6e3b..1260bd7 100644 --- a/resources/views/sites/show.blade.php +++ b/resources/views/sites/show.blade.php @@ -50,5 +50,57 @@
{{ $pages->links() }}
+ +

+ Backlinks ({{ $backlinks->total() }} from {{ number_format($referringDomainsCount) }} referring {{ \Illuminate\Support\Str::plural('domain', $referringDomainsCount) }}) +

+

+ Also links out to {{ number_format($outboundLinksCount) }} {{ \Illuminate\Support\Str::plural('page', $outboundLinksCount) }} on other domains. +

+ +
+ + + + + + + + + + @forelse ($backlinks as $backlink) + + + + + + @empty + + + + @endforelse + +
Referring siteSource pageAnchor text
+ @if ($backlink->site) + + {{ $backlink->site->domain }} + + @else + — + @endif + + @if ($backlink->sitePage) + + {{ $backlink->sitePage->url }} + + @else + — + @endif + {{ $backlink->anchor_text ?? '—' }}
No backlinks found yet.
+
+ +
+ {{ $backlinks->links() }} +