programming
Intro: @extends('parts.app') @section('content') <div class="container"> <h1 class="my-4">Blog Posts</h1> @foreach($blogPosts as $blogPost) <div class="card mb-3"> <div class="card-body"> <h5 class="card-title">{{ $blogPost->title }}</h5> {{-- Display image if it exists --}} @if($blogPost->image) <img src="{{ $blogPost->imageUrl }}" class="img-fluid mb-3" alt="{{ $blogPost->title }}"> @endif {{-- Display video if it exists --}} @if($blogPost->video) <video class="img-fluid mb-3" controls> <source src="{{ $blogPost->videoUrl }}" type="video/mp4"> Your browser does not support the video tag. </video> @endif {{-- Display truncated content with "Read More" button --}} <p class="card-text"> @if(strlen($blogPost->content) > 120) {{ substr($blogPost->content, 0, 120) }}... @else {{ $blogPost->content }} @endif </p> {{-- Read More Button --}} <a href="{{ route('blog.show', $blogPost->id) }}" class="btn btn-primary">Read More</a> </div> </div> @endforeach {{-- Pagination Links --}} <div class="d-flex justify-content-center"> {{ $blogPosts->links() }} </div> </div> @endsection
Back to Blogs