@extends('pemerintah.main')

@section('content')
    <!-- Services -->
    <section class="service-area three pt-100 pb-70">
        <div class="container">
            <div class="section-title">
                <span class="sub-title">Pelatihan</span>
                <h2>We Are Committed To Give Our Best Services</h2>
            </div>
            <div class="row">
                @foreach ($projects as $index => $project)
                    <!-- Menentukan desain berdasarkan index -->
                    @php
                        $designClass = '';
                        switch ($index % 3) {
                            case 0:
                                $designClass = 'service-item';
                                break;
                            case 1:
                                $designClass = 'service-item two';
                                break;
                            case 2:
                                $designClass = 'service-item three';
                                break;
                        }
                    @endphp

                    <div class="col-sm-6 col-lg-4">
                        <div class="{{ $designClass }}">
                            <!-- Tampilkan gambar proyek -->
                            <div class="service-top">
                                <img src="{{ asset('storage/' . $project->foto_proyek) }}"
                                    alt="{{ $project->judul_project }}">
                                <img src="{{ asset('storage/' . $project->foto_proyek) }}">
                            </div>
                            <h3>
                                <a
                                    href="{{ $project->kategori === 'Pelatihan'
                                        ? route('pelatihan.show', $project->id)
                                        : ($project->kategori === 'Pendanaan'
                                            ? route('pendanaan.show', $project->id)
                                            : ($project->kategori === 'Riset'
                                                ? route('riset.show', $project->id)
                                                : ($project->kategori === 'Project Investor'
                                                    ? route('proyek-investor.show', $project->id)
                                                    : '#'))) }}">{{ $project->judul_project }}</a>
                            </h3>
                            <p>{{ Str::words($project->latar_belakang, 100) }}</p>
                            <a class="service-link"
                                href="{{ $project->kategori === 'Pelatihan'
                                    ? route('pelatihan.show', $project->id)
                                    : ($project->kategori === 'Pendanaan'
                                        ? route('pendanaan.show', $project->id)
                                        : ($project->kategori === 'Riset'
                                            ? route('riset.show', $project->id)
                                            : ($project->kategori === 'Project Investor'
                                                ? route('proyek-investor.show', $project->id)
                                                : '#'))) }}">
                                Selengkapnya
                                <i class='bx bx-right-arrow-alt'></i>
                            </a>
                        </div>
                    </div>
                @endforeach
            </div>
        </div>
    </section>
    <!-- End Services -->
@endsection
