some progress
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Models\BrokenLink;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BrokenLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display broken links overview for all sites
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->withCount('brokenLinks')
|
||||
->get();
|
||||
|
||||
// Get broken link statistics
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'sites_with_broken_links' => $sites->where('broken_links_count', '>', 0)->count(),
|
||||
'total_broken_links' => $sites->sum('broken_links_count'),
|
||||
'sites_clean' => $sites->where('broken_links_count', 0)->count(),
|
||||
];
|
||||
|
||||
// Get recent broken links across all sites
|
||||
$recentBrokenLinks = BrokenLink::whereHas('site', function ($query) {
|
||||
$query->where('user_id', auth()->id());
|
||||
})
|
||||
->with('site')
|
||||
->latest()
|
||||
->limit(50)
|
||||
->get();
|
||||
|
||||
return view('broken-links.index', compact('sites', 'stats', 'recentBrokenLinks'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display broken links for a specific site
|
||||
*/
|
||||
public function show(Site $site)
|
||||
{
|
||||
$this->authorize('view', $site);
|
||||
|
||||
$brokenLinks = $site->brokenLinks()
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(50);
|
||||
|
||||
$stats = [
|
||||
'total_broken_links' => $brokenLinks->total(),
|
||||
'unique_urls' => $site->brokenLinks()->distinct('url')->count('url'),
|
||||
];
|
||||
|
||||
return view('broken-links.show', compact('site', 'brokenLinks', 'stats'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user