@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">Permohonan Pendanaan</span>
                <h2>Akademisi, UMKM, Komunitas Mengajukan Permohonan Modal</h2>
            </div>
            <div class="row">
                <form action="{{ route('permohonanpendanaan') }}" method="GET" class="mb-4">
                    <div class="input-group">
                        <input type="text" name="search" value="{{ request('search') }}" class="form-control"
                            placeholder="Cari Pendanaan..." aria-label="Cari Pendanaan...">
                        <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->kategori === 'Pelatihan'
                                    ? route('permohonanpelatihan.show', $project->id)
                                    : ($project->kategori === 'Pendanaan'
                                        ? route('permohonanpendanaan.show', $project->id)
                                        : ($project->kategori === 'Riset'
                                            ? route('permohonanriset.show', $project->id)
                                            : ($project->kategori === 'Project Investor'
                                                ? route('permohonanproyek-investor.show', $project->id)
                                                : '#'))) }}">
                                <img src="{{ asset('storage/' . $project->foto_proyek) }}" alt="Project" class="img-fixed">
                            </a>
                            <div class="blog-bottom">
                                <h3>
                                    <a
                                        href="{{ $project->kategori === 'Pelatihan'
                                            ? route('permohonanpelatihan.show', $project->id)
                                            : ($project->kategori === 'Pendanaan'
                                                ? route('permohonanpendanaan.show', $project->id)
                                                : ($project->kategori === 'Riset'
                                                    ? route('permohonanriset.show', $project->id)
                                                    : ($project->kategori === 'Project Investor'
                                                        ? route('permohonanproyek-investor.show', $project->id)
                                                        : '#'))) }}">{{ $project->judul_project }}</a>
                                </h3>
                                <p>{!! Str::words($project->latar_belakang, 100) !!}</p>
                                <a
                                    href="{{ $project->kategori === 'Pelatihan'
                                        ? route('permohonanpelatihan.show', $project->id)
                                        : ($project->kategori === 'Pendanaan'
                                            ? route('permohonanpendanaan.show', $project->id)
                                            : ($project->kategori === 'Riset'
                                                ? route('permohonanriset.show', $project->id)
                                                : ($project->kategori === 'Project Investor'
                                                    ? route('permohonanproyek-investor.show', $project->id)
                                                    : '#'))) }}">
                                    Selengkapnya
                                    <i class='bx bx-right-arrow-alt'></i>
                                </a>
                            </div>
                        </div>
                    </div>
                @endforeach
                @if (isset($projects) && $projects->count())
                    <div class="pagination-wrapper mt-3">
                        {{ $projects->links() }}
                    </div>
                    @endif
             
            </div>
        </div>
    </section>
    <!-- End Projects -->
@endsection
