add support for egg variables, closes #974
This commit is contained in:
parent
620c624e6f
commit
be6b398e2d
|
@ -7,6 +7,9 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixes an exception thrown when trying to access the `/nests/:id/eggs/:id` API endpoint.
|
* Fixes an exception thrown when trying to access the `/nests/:id/eggs/:id` API endpoint.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
* Adds ability to include egg variables on an API request.
|
||||||
|
|
||||||
## v0.7.1 (Derelict Dermodactylus)
|
## v0.7.1 (Derelict Dermodactylus)
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
|
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace Pterodactyl\Transformers\Api\Application;
|
||||||
use Pterodactyl\Models\Egg;
|
use Pterodactyl\Models\Egg;
|
||||||
use Pterodactyl\Models\Nest;
|
use Pterodactyl\Models\Nest;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
|
use Pterodactyl\Models\EggVariable;
|
||||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||||
|
|
||||||
class EggTransformer extends BaseTransformer
|
class EggTransformer extends BaseTransformer
|
||||||
|
@ -15,7 +16,7 @@ class EggTransformer extends BaseTransformer
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $availableIncludes = [
|
protected $availableIncludes = [
|
||||||
'nest', 'servers', 'config', 'script',
|
'nest', 'servers', 'config', 'script', 'variables',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,4 +148,25 @@ class EggTransformer extends BaseTransformer
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include the variables that are defined for this Egg.
|
||||||
|
*
|
||||||
|
* @param \Pterodactyl\Models\Egg $model
|
||||||
|
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
|
||||||
|
*/
|
||||||
|
public function includeVariables(Egg $model)
|
||||||
|
{
|
||||||
|
if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) {
|
||||||
|
return $this->null();
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->loadMissing('variables');
|
||||||
|
|
||||||
|
return $this->collection(
|
||||||
|
$model->getRelation('variables'),
|
||||||
|
$this->makeTransformer(EggVariableTransformer::class),
|
||||||
|
EggVariable::RESOURCE_NAME
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue