35 lines
953 B
PHP
35 lines
953 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Infolists\Components;
|
|
|
|
use Filament\Infolists\Components\Entry;
|
|
use Filament\Support\Components\Contracts\HasEmbeddedView;
|
|
|
|
class MediaFilesEntry extends Entry implements HasEmbeddedView
|
|
{
|
|
public function toEmbeddedHtml(): string
|
|
{
|
|
$record = $this->getRecord();
|
|
$field = $this->getName();
|
|
|
|
if (! $record) {
|
|
return $this->wrapEmbeddedHtml('<span class="text-sm text-gray-400">-</span>');
|
|
}
|
|
|
|
$files = $record->{$field} ?? [];
|
|
$files = is_array($files) ? array_filter($files) : [];
|
|
|
|
if (empty($files)) {
|
|
return $this->wrapEmbeddedHtml('<span class="text-sm text-gray-400">-</span>');
|
|
}
|
|
|
|
$html = view('filament.infolists.media-player-embed', [
|
|
'patientId' => $record->id,
|
|
'field' => $field,
|
|
])->render();
|
|
|
|
return $this->wrapEmbeddedHtml($html);
|
|
}
|
|
} |