@props([ 'board', 'variant' => 'tenant', 'skin' => 'grid', 'item' => 'card', 'showImage' => true, 'boardLabel' => null, ]) @php use Illuminate\Database\Eloquent\Model; $makePreviewPost = function (int $index) use ($board, $variant): Model { $post = new class extends Model { protected $guarded = []; public ?string $previewThumbnail = null; public function getRouteKeyName(): string { return 'slug'; } public function thumbnailUrl(): ?string { return $this->previewThumbnail; } }; $colors = [ ['#0f172a', '#2563eb'], ['#1d4ed8', '#7c3aed'], ['#0f766e', '#14b8a6'], ]; [$start, $end] = $colors[$index % count($colors)]; $svg = sprintf( "", $start, $end ); $post->forceFill([ 'slug' => 'preview-post-' . ($index + 1), 'title' => sprintf('미리보기 샘플 글 %d', $index + 1), 'content' => '

선택한 아이템 모양을 확인하기 위한 샘플 본문입니다. 실제 글 내용은 사용하지 않습니다.

', 'published_at' => now()->subDays($index), 'created_at' => now()->subDays($index + 1), 'updated_at' => now()->subDays($index + 1), 'thumbnail' => 'preview-' . ($index + 1) . '.svg', ]); $post->previewThumbnail = 'data:image/svg+xml;charset=UTF-8,' . rawurlencode($svg); $post->setRelation('board', $board); $post->setRelation('boardCategory', (object) [ 'name' => $index % 2 === 0 ? '공지' : '일반', ]); return $post; }; $posts = collect(range(0, 2))->map($makePreviewPost); @endphp