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'));
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,27 @@ use Illuminate\View\View;
|
||||
|
||||
class DnsRecordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display overview of all DNS records across all sites
|
||||
*/
|
||||
public function overview(): View
|
||||
{
|
||||
$sites = Site::where('user_id', Auth::id())
|
||||
->withCount('dnsRecords')
|
||||
->with(['dnsRecords' => function ($query) {
|
||||
$query->where('is_active', true)->limit(5);
|
||||
}])
|
||||
->get();
|
||||
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'total_dns_records' => $sites->sum('dns_records_count'),
|
||||
'sites_with_records' => $sites->where('dns_records_count', '>', 0)->count(),
|
||||
];
|
||||
|
||||
return view('dns-records.overview', compact('sites', 'stats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the DNS records for a site.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\CheckDomainExpiry;
|
||||
use App\Models\Domain;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DomainController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$domains = Domain::with('site')
|
||||
->where('is_active', true)
|
||||
->orderBy('expires_at', 'asc')
|
||||
->paginate(15);
|
||||
|
||||
return view('domains.index', compact('domains'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('domains.create', compact('sites'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
'domain' => 'required|string|max:255',
|
||||
'is_active' => 'sometimes|nullable|in:on,off',
|
||||
]);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
$domain = Domain::create($validated);
|
||||
|
||||
// Dispatch job to check domain immediately
|
||||
CheckDomainExpiry::dispatch($domain);
|
||||
|
||||
return redirect()
|
||||
->route('domains.index')
|
||||
->with('success', 'Domain added successfully. Checking expiry date...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Domain $domain)
|
||||
{
|
||||
$domain->load('site');
|
||||
|
||||
return view('domains.show', compact('domain'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Domain $domain)
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('domains.edit', compact('domain', 'sites'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Domain $domain)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
'domain' => 'required|string|max:255',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
$domain->update($validated);
|
||||
|
||||
return redirect()
|
||||
->route('domains.index')
|
||||
->with('success', 'Domain updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Domain $domain)
|
||||
{
|
||||
$domain->delete();
|
||||
|
||||
return redirect()
|
||||
->route('domains.index')
|
||||
->with('success', 'Domain deleted successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually trigger domain expiry check
|
||||
*/
|
||||
public function check(Domain $domain)
|
||||
{
|
||||
CheckDomainExpiry::dispatch($domain);
|
||||
|
||||
return back()
|
||||
->with('success', 'Domain expiry check has been queued.');
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,27 @@ use Illuminate\View\View;
|
||||
|
||||
class HealthCheckController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display overview of all health checks across all sites
|
||||
*/
|
||||
public function overview(): View
|
||||
{
|
||||
$sites = Site::where('user_id', Auth::id())
|
||||
->withCount('healthChecks')
|
||||
->with(['healthChecks' => function ($query) {
|
||||
$query->where('is_active', true)->limit(5);
|
||||
}])
|
||||
->get();
|
||||
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'total_health_checks' => $sites->sum('health_checks_count'),
|
||||
'sites_with_checks' => $sites->where('health_checks_count', '>', 0)->count(),
|
||||
];
|
||||
|
||||
return view('health-checks.overview', compact('sites', 'stats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the health checks for a site.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\CheckSitemap;
|
||||
use App\Models\Sitemap;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$sitemaps = Sitemap::with('site')
|
||||
->where('is_active', true)
|
||||
->orderBy('is_valid', 'asc')
|
||||
->orderBy('last_checked_at', 'desc')
|
||||
->paginate(15);
|
||||
|
||||
return view('sitemaps.index', compact('sitemaps'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('sitemaps.create', compact('sites'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
'url' => 'required|url|max:500',
|
||||
'is_active' => 'sometimes|nullable|in:on,off',
|
||||
]);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
$sitemap = Sitemap::create($validated);
|
||||
|
||||
// Dispatch job to check sitemap immediately
|
||||
CheckSitemap::dispatch($sitemap);
|
||||
|
||||
return redirect()
|
||||
->route('sitemaps.index')
|
||||
->with('success', 'Sitemap added successfully. Validating now...');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Sitemap $sitemap)
|
||||
{
|
||||
$sitemap->load('site');
|
||||
|
||||
return view('sitemaps.show', compact('sitemap'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Sitemap $sitemap)
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('sitemaps.edit', compact('sitemap', 'sites'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Sitemap $sitemap)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'site_id' => 'required|exists:sites,id',
|
||||
'url' => 'required|url|max:500',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$validated['is_active'] = $request->has('is_active');
|
||||
|
||||
$sitemap->update($validated);
|
||||
|
||||
return redirect()
|
||||
->route('sitemaps.index')
|
||||
->with('success', 'Sitemap updated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Sitemap $sitemap)
|
||||
{
|
||||
$sitemap->delete();
|
||||
|
||||
return redirect()
|
||||
->route('sitemaps.index')
|
||||
->with('success', 'Sitemap deleted successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually trigger sitemap validation
|
||||
*/
|
||||
public function check(Sitemap $sitemap)
|
||||
{
|
||||
CheckSitemap::dispatch($sitemap);
|
||||
|
||||
return back()
|
||||
->with('success', 'Sitemap validation has been queued.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Models\SslCertificate;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SslCertificateController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display SSL certificate overview for all sites
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->with(['sslCertificates' => function ($query) {
|
||||
$query->latest()->limit(1);
|
||||
}])
|
||||
->get();
|
||||
|
||||
// Get SSL statistics
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'valid_certs' => 0,
|
||||
'expiring_soon' => 0,
|
||||
'expired' => 0,
|
||||
];
|
||||
|
||||
foreach ($sites as $site) {
|
||||
$latestCert = $site->sslCertificates->first();
|
||||
if ($latestCert) {
|
||||
if ($latestCert->expires_at) {
|
||||
$daysUntilExpiry = now()->diffInDays($latestCert->expires_at, false);
|
||||
|
||||
if ($daysUntilExpiry < 0) {
|
||||
$stats['expired']++;
|
||||
} elseif ($daysUntilExpiry <= 30) {
|
||||
$stats['expiring_soon']++;
|
||||
} else {
|
||||
$stats['valid_certs']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get recent SSL checks across all sites
|
||||
$recentCertificates = SslCertificate::whereHas('site', function ($query) {
|
||||
$query->where('user_id', auth()->id());
|
||||
})
|
||||
->with('site')
|
||||
->latest()
|
||||
->limit(50)
|
||||
->get();
|
||||
|
||||
return view('ssl.index', compact('sites', 'stats', 'recentCertificates'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display SSL certificate details for a specific site
|
||||
*/
|
||||
public function show(Site $site)
|
||||
{
|
||||
$this->authorize('view', $site);
|
||||
|
||||
$sslCertificates = $site->sslCertificates()
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(50);
|
||||
|
||||
$latestCert = $site->sslCertificates()->latest()->first();
|
||||
|
||||
return view('ssl.show', compact('site', 'sslCertificates', 'latestCert'));
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,27 @@ use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TcpPortController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display overview of all TCP ports across all sites
|
||||
*/
|
||||
public function overview()
|
||||
{
|
||||
$sites = Site::where('user_id', Auth::id())
|
||||
->withCount('tcpPorts')
|
||||
->with(['tcpPorts' => function ($query) {
|
||||
$query->where('is_active', true)->limit(5);
|
||||
}])
|
||||
->get();
|
||||
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'total_ports_monitored' => $sites->sum('tcp_ports_count'),
|
||||
'sites_with_ports' => $sites->where('tcp_ports_count', '>', 0)->count(),
|
||||
];
|
||||
|
||||
return view('tcp-ports.overview', compact('sites', 'stats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Models\UptimeCheck;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UptimeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display uptime monitoring overview for all sites
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$sites = Site::where('user_id', auth()->id())
|
||||
->with(['uptimeChecks' => function ($query) {
|
||||
$query->latest()->limit(1);
|
||||
}])
|
||||
->get();
|
||||
|
||||
// Get uptime statistics
|
||||
$stats = [
|
||||
'total_sites' => $sites->count(),
|
||||
'sites_up' => 0,
|
||||
'sites_down' => 0,
|
||||
'avg_response_time' => 0,
|
||||
];
|
||||
|
||||
$totalResponseTime = 0;
|
||||
$checksCount = 0;
|
||||
|
||||
foreach ($sites as $site) {
|
||||
$latestCheck = $site->uptimeChecks->first();
|
||||
if ($latestCheck) {
|
||||
if ($latestCheck->is_online) {
|
||||
$stats['sites_up']++;
|
||||
} else {
|
||||
$stats['sites_down']++;
|
||||
}
|
||||
$totalResponseTime += $latestCheck->response_time ?? 0;
|
||||
$checksCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($checksCount > 0) {
|
||||
$stats['avg_response_time'] = round($totalResponseTime / $checksCount, 2);
|
||||
}
|
||||
|
||||
// Get recent checks across all sites
|
||||
$recentChecks = UptimeCheck::whereHas('site', function ($query) {
|
||||
$query->where('user_id', auth()->id());
|
||||
})
|
||||
->with('site')
|
||||
->latest()
|
||||
->limit(50)
|
||||
->get();
|
||||
|
||||
return view('uptime.index', compact('sites', 'stats', 'recentChecks'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display uptime details for a specific site
|
||||
*/
|
||||
public function show(Site $site)
|
||||
{
|
||||
$this->authorize('view', $site);
|
||||
|
||||
$uptimeChecks = $site->uptimeChecks()
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(100);
|
||||
|
||||
// Calculate uptime percentage for last 30 days
|
||||
$checksLast30Days = $site->uptimeChecks()
|
||||
->where('created_at', '>=', now()->subDays(30))
|
||||
->get();
|
||||
|
||||
$uptimePercentage = 0;
|
||||
if ($checksLast30Days->count() > 0) {
|
||||
$upCount = $checksLast30Days->where('is_online', true)->count();
|
||||
$uptimePercentage = round(($upCount / $checksLast30Days->count()) * 100, 2);
|
||||
}
|
||||
|
||||
return view('uptime.show', compact('site', 'uptimeChecks', 'uptimePercentage'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user