Finish base API.
Making PR, any additional API functions or modifications can be done within the repository now.
This commit is contained in:
parent
77e3744b40
commit
ac65d5fa21
8 changed files with 249 additions and 6 deletions
47
app/Http/Controllers/API/ServiceController.php
Normal file
47
app/Http/Controllers/API/ServiceController.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Transformers\ServiceTransformer;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @Resource("Services")
|
||||
*/
|
||||
class ServiceController extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getServices(Request $request)
|
||||
{
|
||||
return Models\Service::all();
|
||||
}
|
||||
|
||||
public function getService(Request $request, $id)
|
||||
{
|
||||
$service = Models\Service::find($id);
|
||||
if (!$service) {
|
||||
throw new NotFoundHttpException('No service by that ID was found.');
|
||||
}
|
||||
|
||||
$options = Models\ServiceOptions::select('id', 'name', 'description', 'tag', 'docker_image')->where('parent_service', $service->id)->get();
|
||||
foreach($options as &$opt) {
|
||||
$opt->variables = Models\ServiceVariables::where('option_id', $opt->id)->get();
|
||||
}
|
||||
|
||||
return [
|
||||
'service' => $service,
|
||||
'options' => $options
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue