<?php

namespace App\Http\Controllers\Api;

use App\Http\Resources\PermissionResource;
use App\Models\Permission;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;

class PermissionController extends ApiController
{
    public function index(Request $request): AnonymousResourceCollection
    {
        // Permissions are global
        $permissions = Permission::query()
            ->orderBy('module')
            ->orderBy('name')
            ->get();

        return PermissionResource::collection($permissions);
    }
}
