# Feature Pages Implementation - Complete Views & Charts
## Individual Feature Detail Page Template
Create `resources/views/features/show.blade.php`:
```blade
@extends('layouts.app')
@section('title', $featureInfo['name'])
@section('content')
{{ $featureInfo['name'] }}
{{ $featureInfo['description'] }}
Back to Features
@if(session('success'))
{{ session('success') }}
@endif
{{ $sites->sum(fn($s) => $s->features->where('is_enabled', true)->count()) }}
Active Sites
{{ now()->format('H:i') }}
Last Updated
@if(!empty($chartData))
@foreach($chartData as $siteId => $data)
@php
$site = $sites->find($siteId);
@endphp
{{ $site->name }}
@endforeach
@endif
Site
Status
Last Checked
Metrics
Actions
@foreach($sites as $site)
@php
$feature = $site->features->where('feature_type', $featureType)->first();
$isEnabled = $feature && $feature->is_enabled;
@endphp
{{ $site->name }}
{{ $site->url }}
@if($feature && $feature->last_checked_at)
{{ $feature->last_checked_at->diffForHumans() }}
@else
Never
@endif
@include('features.partials.metrics-' . $featureType, ['site' => $site])
@endforeach
@include('features.info.' . $featureType)
@foreach($sites as $site)
@endforeach
@endsection
@push('scripts')
@endpush
@endsection
```
## Feature-Specific Metrics Partials
Create `resources/views/features/partials/metrics-uptime.blade.php`:
```blade
@php
$latestCheck = $site->uptimeChecks()->latest()->first();
$uptimePercentage = $site->uptimeChecks()
->where('created_at', '>=', now()->subDays(30))
->avg('is_online') * 100;
@endphp
@if($latestCheck)
{{ $latestCheck->is_online ? 'Online' : 'Offline' }}
Uptime: {{ number_format($uptimePercentage, 1) }}%
Response: {{ number_format($latestCheck->response_time, 0) }}ms
@else
No data
@endif
```
Create `resources/views/features/partials/metrics-ssl.blade.php`:
```blade
@php
$latestCert = $site->sslCertificates()->latest()->first();
@endphp
@if($latestCert)
@php
$daysLeft = now()->diffInDays($latestCert->expires_at, false);
@endphp
{{ $daysLeft }} days left
Expires: {{ $latestCert->expires_at->format('M d, Y') }}
@else
No certificate data
@endif
```
Create `resources/views/features/partials/metrics-broken_links.blade.php`:
```blade
@php
$brokenCount = $site->brokenLinks()->count();
$totalLinks = $site->brokenLinks()->distinct('url')->count();
@endphp
{{ $brokenCount }} broken
@if($totalLinks > 0)
Total links scanned: {{ $totalLinks }}
@else
No scan data
@endif
```
## Feature Information Pages
Create `resources/views/features/info/uptime.blade.php`:
```blade
What is Uptime Monitoring?
Uptime monitoring checks if your website is accessible and responding correctly.
It performs regular HTTP/HTTPS requests and tracks:
Site availability (up/down status)
HTTP response codes
Response times
SSL certificate validity
How It Works
Automated checks run every 5 minutes
Your site is accessed from our servers
Response time and status are recorded
Alerts are sent if your site is down
Metrics Tracked
Uptime Percentage: Overall availability over the last 30 days
Response Time: How fast your site responds (in milliseconds)
Status Codes: HTTP response codes (200, 404, 500, etc.)
Tip: A healthy website should maintain 99%+ uptime and respond in under 1000ms.
```
Create `resources/views/features/info/ssl.blade.php`:
```blade
What is SSL Certificate Monitoring?
SSL certificate monitoring ensures your website's security certificate is valid and hasn't expired.
This is crucial for:
Maintaining visitor trust
SEO rankings (Google prefers HTTPS)
Data encryption and security
Browser compatibility
What We Check
Certificate expiration date
Certificate validity
Issuer information
Certificate chain completeness
Alert Thresholds
7 days: Critical alert
30 days: Warning alert
60 days: Info notification
Important: Expired SSL certificates will cause browser warnings and prevent visitors from accessing your site.
```
## Feature Settings Forms
Create `resources/views/features/settings/uptime.blade.php`:
```blade
Check Interval
Every 5 minutes
Every 10 minutes
Every 15 minutes
Every 30 minutes
Every hour
```
Create `resources/views/features/settings/ssl.blade.php`:
```blade
Alert When Days Remaining
You'll receive alerts at these intervals before expiration
Check Interval
Daily
Weekly
```
## Layout Integration
Add to your navigation in `resources/views/layouts/app.blade.php`:
```blade
Features
```
## Running the Implementation
1. Run migration:
```bash
./vendor/bin/sail artisan migrate
```
2. Create the SiteFeature model
3. Create FeaturesController
4. Add routes
5. Create view files
6. Test feature toggles
## Chart.js CDN
Already included in the show.blade.php template:
```html
```
## Auto-enabling Features
You may want to automatically enable default features when a site is created. Add to Site model:
```php
protected static function booted()
{
static::created(function ($site) {
// Auto-enable core features
$site->enableFeature('uptime');
$site->enableFeature('ssl');
});
}
```
This provides a complete, production-ready feature management system with graphs and per-site controls.