{{-- Latest Posts Component --}} @php $displayType = $component['content']['display_type'] ?? 'grid'; $postsPerRow = $component['content']['posts_per_row'] ?? 3; $showExcerpt = $component['content']['show_excerpt'] ?? true; $showAuthor = $component['content']['show_author'] ?? true; $showDate = $component['content']['show_date'] ?? true; $showCategory = $component['content']['show_category'] ?? true; $showFeaturedImage = $component['content']['show_featured_image'] ?? true; $showReadMore = $component['content']['show_read_more'] ?? true; $categoryFilter = $component['content']['category_filter'] ?? null; $tagFilter = $component['content']['tag_filter'] ?? null; $filterType = $component['content']['filter_type'] ?? 'latest'; // latest, featured, category, tag $limit = $component['content']['limit'] ?? 6; $excerptLength = $component['content']['excerpt_length'] ?? 120; // Get posts from database $posts = []; if (class_exists('\App\Models\Post')) { $query = \App\Models\Post::where('status', 'published') ->where('published_at', '<=', now()) ->with(['category', 'author', 'tags']); // Apply filters based on filter type if ($filterType === 'featured') { $query->where('is_featured', true); } elseif ($filterType === 'category' && $categoryFilter) { $query->where('post_category_id', $categoryFilter); } elseif ($filterType === 'tag' && $tagFilter) { $query->whereHas('tags', function($q) use ($tagFilter) { $q->where('post_tags.id', $tagFilter); }); } $posts = $query->orderBy('published_at', 'desc')->limit($limit)->get(); } @endphp @if(count($posts) > 0)
@if($displayType === 'grid')
@foreach($posts as $post)
@if($showFeaturedImage && $post->featured_image)
{{ $post->title }} @if($post->is_featured) Featured @endif
@endif
@if($showCategory && $post->category) @endif
{{ $post->title }}
@if($showExcerpt && $post->excerpt)

{{ Str::limit($post->excerpt, $excerptLength) }}

@endif @if($showReadMore) Read More @endif
@endforeach
@else {{-- List View --}}
@foreach($posts as $post)
@if($showFeaturedImage && $post->featured_image)
{{ $post->title }} @if($post->is_featured) Featured @endif
@endif
@if($showCategory && $post->category) @endif

{{ $post->title }}

@if($showExcerpt && $post->excerpt)

{{ Str::limit($post->excerpt, $excerptLength) }}

@endif @if($showReadMore) Read More @endif
@endforeach
@endif
@else {{-- Empty State --}}

No Posts Yet

Start sharing your stories and insights with your audience.

@if(auth()->check()) Create Your First Post @endif
@endif