1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-10-28 04:42:29 +01:00
Pterodactyl-Panel/app/Services/Api/PermissionService.php

59 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2017-09-26 04:43:01 +02:00
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
2017-09-26 04:43:01 +02:00
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
2017-07-09 19:29:18 +02:00
namespace Pterodactyl\Services\Api;
use Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface;
2017-07-09 19:29:18 +02:00
class PermissionService
{
/**
* @var \Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface
*/
protected $repository;
/**
* ApiPermissionService constructor.
*
* @param \Pterodactyl\Contracts\Repository\ApiPermissionRepositoryInterface $repository
*/
public function __construct(ApiPermissionRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* Store a permission key in the database.
*
2017-08-22 05:10:48 +02:00
* @param string $key
* @param string $permission
* @return bool
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function create($key, $permission)
{
// @todo handle an array of permissions to do a mass assignment?
return $this->repository->withoutFresh()->create([
'key_id' => $key,
'permission' => $permission,
]);
}
/**
* Return all of the permissions available for an API Key.
*
* @return array
*/
public function getPermissions()
{
return $this->repository->getModel()::CONST_PERMISSIONS;
}
}