<?php

namespace Kanakku\Http\Controllers\V1\Onboarding;

use Kanakku\Space\PermissionsChecker;
use Illuminate\Http\JsonResponse;
use Kanakku\Http\Controllers\Controller;

class PermissionsController extends Controller
{
    /**
     * @var PermissionsChecker
     */
    protected $permissions;

    /**
     * @param PermissionsChecker $checker
     */
    public function __construct(PermissionsChecker $checker)
    {
        $this->permissions = $checker;
    }

    /**
     * Display the permissions check page.
     *
     * @return JsonResponse
     */
    public function permissions()
    {
        $permissions = $this->permissions->check(
            config('installer.permissions')
        );

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