@extends('pemerintah.main')

@section('content')
    <style>
        .img-fixed {
            width: 500%;
            /* Full width */
            height: auto;
            /* Maintain aspect ratio */
            max-height: 200px;
            /* Set a maximum height */
            object-fit: contain;
            /* Ensure the full image is visible */
        }
    </style>
    <!-- Projects -->
    <section class="projects-area pt-100 pb-70">
        <div class="container">
            <div class="section-title">
                <span class="sub-title">Penawaran Pelatihan</span>
                <h2>Investor dan Akademisi Menawarkan Program Pelatihan</h2>
            </div>
            <div class="row">
                <form action="{{ route('penawaranpelatihan') }}" method="GET" class="mb-4">
                    <div class="input-group">
                        <input type="text" name="search" value="{{ request('search') }}" class="form-control" placeholder="Cari Pelatihan..." aria-label="Cari Pelatihan...">
                        <div class="input-group-append">
                            <button type="submit" class="btn btn-primary">Cari</button>
                        </div>
                    </div>
                </form>
                
                @foreach ($projects as $project)
                    <div class="col-sm-6 offset-sm-3 offset-lg-0 col-lg-4">
                        <div class="blog-item">
                            <a
                                href="{{ $project->jenis_penawaran === 'pelatihan'
                                    ? route('penawaranpelatihan.show', $project->id)
                                    : ($project->jenis_penawaran === 'pendanaan'
                                        ? route('penawaranpendanaan.show', $project->id)
                                        : ($project->jenis_penawaran === 'riset'
                                            ? route('penawaranriset.show', $project->id)
                                            : '#')) }}">
                                <img src="{{ asset('storage/' . $project->foto_proyek) }}" alt="Project" class="img-fixed">
                            </a>
                            <div class="blog-bottom">
                                <h3>
                                    <a
                                        href="{{ $project->jenis_penawaran === 'pelatihan'
                                            ? route('penawaranpelatihan.show', $project->id)
                                            : ($project->jenis_penawaran === 'pendanaan'
                                                ? route('penawaranpendanaan.show', $project->id)
                                                : ($project->jenis_penawaran === 'riset'
                                                    ? route('penawaranriset.show', $project->id)
                                                    : '#')) }}">{{ $project->judul_project }}</a>
                                </h3>
                                <p>{!! Str::words($project->deskripsi_project, 100) !!}</p>
                                <a
                                    href="{{ $project->jenis_penawaran === 'pelatihan'
                                        ? route('penawaranpelatihan.show', $project->id)
                                        : ($project->jenis_penawaran === 'pendanaan'
                                            ? route('penawaranpendanaan.show', $project->id)
                                            : ($project->jenis_penawaran === 'riset'
                                                ? route('penawaranriset.show', $project->id)
                                                : '#')) }}">
                                    Selengkapnya
                                    <i class='bx bx-right-arrow-alt'></i>
                                </a>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>
             <!-- Pagination Links -->
             <div class="mt-4">
                {{ $projects->withQueryString()->links() }}
            </div>
        </div>
    </section>
    <!-- End Projects -->
@endsection
