<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Alumni;
use Illuminate\Http\Request;

class AlumniController extends Controller
{
    public function index()
    {
        $alumnis = \App\Models\Alumni::orderBy('tahun_lulus', 'desc')->get();

        $data = $alumnis->map(function ($alumni) {
            return [
                'id' => $alumni->id,
                'nama' => $alumni->nama_santri,
                'angkatan' => $alumni->tahun_lulus,
                'aktivitas_setelah_lulus' => $alumni->aktivitas_setelah_lulus,
                'kontak' => $alumni->kontak,
                'keterangan' => $alumni->keterangan,
            ];
        });

        return response()->json(['data' => $data]);
    }
} 