2020-10-04 20:25:58 +00:00
|
|
|
<?php
|
|
|
|
|
2020-12-28 04:57:31 +00:00
|
|
|
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;
|
|
|
|
|
2020-12-28 04:57:31 +00:00
|
|
|
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)
|
|
|
|
{
|
2020-12-28 04:57:31 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|