Skip to main content

Infrastructure

Forge Backup Config Card code

Copy the implementation or inspect every file that belongs to this component unit.

resources/views/components/ui/forge-backup-config-card.blade.php

@props([
    'name',
    'databases' => [],
    'provider' => null,
    'frequency' => null,
    'retention' => null,
    'status' => 'Healthy',
    'statusVariant' => 'green',
    'lastRun' => null,
    'nextRun' => null,
    'failureEmail' => null,
])

@php
    /*
    | Automated database backup configuration card. Shows storage provider,
    | schedule, retention, recent run state and failure notification email.
    |
    | Usage:
    |   <x-ui.forge-backup-config-card name="Production backups" :databases="['app']" />
    */
    $databases = collect($databases)->filter()->values();
@endphp

<article {{ $attributes->merge(['class' => 'min-w-0 rounded-xl border border-gray-200 bg-white p-5 shadow-sm dark:border-gray-800 dark:bg-gray-900']) }}>
    <div class="flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
        <div class="min-w-0">
            <p class="truncate text-sm font-semibold text-gray-900 dark:text-white">{{ $name }}</p>
            @if ($provider)
                <p class="mt-1 truncate text-xs text-gray-500 dark:text-gray-400">{{ $provider }}</p>
            @endif
        </div>

        <x-ui.badge :variant="$statusVariant" size="sm" dot class="w-fit sm:shrink-0">{{ $status }}</x-ui.badge>
    </div>

    <div class="mt-4 flex flex-wrap gap-1.5">
        @foreach ($databases as $database)
            <x-ui.badge variant="gray" size="sm">{{ $database }}</x-ui.badge>
        @endforeach
    </div>

    <x-ui.status-bar class="mt-5" :items="array_values(array_filter([
        $frequency ? ['icon' => 'calendar-check', 'label' => 'Frequency', 'value' => $frequency] : null,
        $retention ? ['icon' => 'archive', 'label' => 'Retention', 'value' => $retention] : null,
        $lastRun ? ['icon' => 'clock-counter-clockwise', 'label' => 'Last run', 'value' => $lastRun] : null,
        $nextRun ? ['icon' => 'timer', 'label' => 'Next run', 'value' => $nextRun] : null,
        $failureEmail ? ['icon' => 'envelope-simple', 'label' => 'Failures', 'value' => $failureEmail] : null,
    ]))" />
</article>