misc_pterodactyl-panel/app/Http/Controllers/Api/Application/RoleController.php

77 lines
1.8 KiB
PHP
Raw Normal View History

2020-10-04 20:25:58 +00:00
<?php
namespace Pterodactyl\Http\Controllers\Api\Application;
2020-10-04 20:25:58 +00:00
use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Requests\Admin\RoleFormRequest;
use Pterodactyl\Repositories\Eloquent\AdminRolesRepository;
class RoleController extends ApplicationApiController
2020-10-04 20:25:58 +00:00
{
/**
* @var \Pterodactyl\Repositories\Eloquent\AdminRolesRepository
*/
private $repository;
/**
* RolesController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\AdminRolesRepository $repository
*/
public function __construct(AdminRolesRepository $repository)
{
parent::__construct();
2020-10-04 20:25:58 +00:00
$this->repository = $repository;
}
/**
* Returns an array of all roles.
*
* @return \Illuminate\Http\JsonResponse
*/
public function index()
{
return new JsonResponse($this->repository->all());
}
/**
* Creates a new role.
*
* @param \Pterodactyl\Http\Requests\Admin\RoleFormRequest $request
*
* @return \Illuminate\Http\JsonResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function create(RoleFormRequest $request)
{
$role = $this->repository->create($request->normalize());
return new JsonResponse($role);
}
/**
* Updates a role.
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
*/
public function update()
{
return response('', 204);
}
/**
* Deletes a role.
*
* @param int $role_id
*
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
*/
public function delete(int $role_id)
{
$this->repository->delete($role_id);
return response('', 204);
}
}