<?php

namespace App\Http\Controllers\API;

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

class AuditLogController extends Controller
{
    public function index(Request $request)
    {
        $user = $request->user();
        if ($user && $user->role !== 'super_admin') {
            return response()->json(['success' => false, 'message' => 'Unauthorized audit log access'], 403);
        }

        $logs = AuditLog::orderBy('created_at', 'desc')->take(100)->get();
        return response()->json(['success' => true, 'data' => $logs]);
    }
}
