95 lines
4 KiB
PHP
95 lines
4 KiB
PHP
<?php
|
|
|
|
use App\Models\Certificate;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
new #[Title('Certificate details')] class extends Component {
|
|
public Certificate $certificate;
|
|
|
|
public function mount(Certificate $certificate): void
|
|
{
|
|
// Route-model binding respects the global scope, so a foreign
|
|
// certificate resolves to a 404.
|
|
$this->certificate = $certificate;
|
|
}
|
|
|
|
public function getStatusProperty()
|
|
{
|
|
return $this->certificate->expiryStatus(Auth::user()->reminder_months_before);
|
|
}
|
|
|
|
public function getFileExtensionProperty(): ?string
|
|
{
|
|
if (blank($this->certificate->file_path)) {
|
|
return null;
|
|
}
|
|
|
|
return strtolower(pathinfo($this->certificate->file_path, PATHINFO_EXTENSION));
|
|
}
|
|
}; ?>
|
|
|
|
<section class="mx-auto flex w-full max-w-3xl flex-col gap-6">
|
|
<div class="flex flex-wrap items-start justify-between gap-4">
|
|
<div>
|
|
<flux:heading size="xl">{{ $certificate->title }}</flux:heading>
|
|
<flux:text class="mt-1">{{ __('Certificate details') }}</flux:text>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<flux:badge :color="$this->status->color()">{{ $this->status->label() }}</flux:badge>
|
|
<flux:button :href="route('certificates.edit', $certificate)" wire:navigate icon="pencil-square">
|
|
{{ __('Edit') }}
|
|
</flux:button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm sm:p-8 dark:border-zinc-800 dark:bg-zinc-900">
|
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
<flux:input :label="__('Title')" :value="$certificate->title" readonly />
|
|
<flux:input :label="__('Category')" :value="$certificate->category?->name ?? '—'" readonly />
|
|
<flux:input :label="__('Issuing authority')" :value="$certificate->issuer ?? '—'" readonly />
|
|
<flux:input :label="__('Certificate number')" :value="$certificate->certificate_number ?? '—'" readonly />
|
|
<flux:input :label="__('Holder last name')" :value="$certificate->holder_last_name ?? '—'" readonly />
|
|
<flux:input :label="__('Issue date')" :value="$certificate->issued_at?->format('M j, Y') ?? '—'" readonly />
|
|
<flux:input :label="__('Expiry date')" :value="$certificate->expires_at->format('M j, Y')" readonly />
|
|
</div>
|
|
|
|
@if ($certificate->notes)
|
|
<div class="mt-4">
|
|
<flux:textarea :label="__('Notes')" :value="$certificate->notes" rows="3" readonly />
|
|
</div>
|
|
@endif
|
|
|
|
<div class="mt-6 flex items-center gap-3">
|
|
<flux:button :href="route('certificates.download', $certificate)" variant="ghost" icon="arrow-down-tray">
|
|
{{ __('Download') }}
|
|
</flux:button>
|
|
<flux:button :href="route('certificates.index')" wire:navigate variant="ghost">
|
|
{{ __('Back to certificates') }}
|
|
</flux:button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="overflow-hidden rounded-2xl border border-zinc-200 bg-white shadow-sm dark:border-zinc-800 dark:bg-zinc-900">
|
|
@if (blank($certificate->file_path))
|
|
<div class="flex flex-col items-center gap-2 p-12 text-center">
|
|
<flux:icon.document class="size-8 text-zinc-400" />
|
|
<flux:text>{{ __('No document was uploaded for this certificate.') }}</flux:text>
|
|
</div>
|
|
@elseif (in_array($this->fileExtension, ['jpg', 'jpeg', 'png'], true))
|
|
<img
|
|
src="{{ route('certificates.preview', $certificate) }}"
|
|
alt="{{ $certificate->title }}"
|
|
class="max-h-[75vh] w-full object-contain"
|
|
/>
|
|
@else
|
|
<iframe
|
|
src="{{ route('certificates.preview', $certificate) }}"
|
|
class="h-[75vh] w-full"
|
|
title="{{ $certificate->title }}"
|
|
></iframe>
|
|
@endif
|
|
</div>
|
|
</section>
|