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.
31 lines
860 B
PHP
31 lines
860 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Site;
|
|
use Illuminate\Contracts\View\View;
|
|
|
|
class SiteController extends Controller
|
|
{
|
|
public function show(Site $site): View
|
|
{
|
|
$pages = $site->pages()->orderBy('url')->paginate(50, ['*'], 'pages_page');
|
|
|
|
$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,
|
|
]);
|
|
}
|
|
}
|