2018-01-13 20:08:19 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-20 01:58:57 +00:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
|
2018-01-13 20:08:19 +00:00
|
|
|
|
|
|
|
use Pterodactyl\Models\Node;
|
|
|
|
use Pterodactyl\Models\Allocation;
|
|
|
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
2018-01-20 03:47:06 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
2018-01-13 20:08:19 +00:00
|
|
|
|
2018-01-20 03:47:06 +00:00
|
|
|
class DeleteAllocationRequest extends ApplicationApiRequest
|
2018-01-13 20:08:19 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $permission = AdminAcl::WRITE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if the requested allocation exists and belongs to the node that
|
|
|
|
* is being passed in the URL.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function resourceExists(): bool
|
|
|
|
{
|
|
|
|
$node = $this->route()->parameter('node');
|
|
|
|
$allocation = $this->route()->parameter('allocation');
|
|
|
|
|
|
|
|
if ($node instanceof Node && $node->exists) {
|
|
|
|
if ($allocation instanceof Allocation && $allocation->exists && $allocation->node_id === $node->id) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|