Refactor featured image display in PagesTable: Replaced the existing image column with a text column that conditionally displays either the featured image or a default SVG icon. Enhanced the HTML rendering for better visual representation and alignment in the table.

This commit is contained in:
Ümit Tunç
2025-11-04 15:16:05 -03:00
parent 9dd1bde863
commit 38850c7e32
@@ -21,11 +21,21 @@ class PagesTable
{
return $table
->columns([
ImageColumn::make('featured_image_url')
TextColumn::make('featured_image')
->label(__('pages.table_column_featured_image'))
->circular()
->size(40)
->defaultImageUrl('/images/placeholder-page.png'),
->formatStateUsing(function ($state, $record) {
// Eğer featured_image varsa image göster
if ($record->featured_image_url) {
return '<img src="' . e($record->featured_image_url) . '" alt="" class="w-10 h-10 rounded-full object-cover" />';
}
// Yoksa Heroicon page icon'unu göster (dark mode'da beyaz, light mode'da siyah)
$svgIcon = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="h-10 w-10"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" /></svg>';
return '<div class="flex items-center justify-center w-10 h-10 rounded-full bg-gray-100 dark:bg-gray-800 text-gray-950 dark:text-white">' . $svgIcon . '</div>';
})
->html()
->alignCenter(),
TextColumn::make('title')
->label(__('pages.table_column_title'))