mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 07:16:51 +01:00 
			
		
		
		
	 e313dff674
			
		
	
	
		e313dff674
		
			
		
	
	
	
	
		
			
			Changes the API internals to use normal Laravel binding which automatically supports nested-models and can determine their relationships. This removes a lot of confusingly complex internal logic and replaces it with standard Laravel code. This also removes a deprecated "getModel" method and fully replaces it with a "parameter" method that does stricter type-checking.
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
 | |
| 
 | |
| use Pterodactyl\Models\User;
 | |
| use Pterodactyl\Models\Server;
 | |
| use Pterodactyl\Services\Servers\StartupModificationService;
 | |
| use Pterodactyl\Transformers\Api\Application\ServerTransformer;
 | |
| use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
 | |
| use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest;
 | |
| 
 | |
| class StartupController extends ApplicationApiController
 | |
| {
 | |
|     /**
 | |
|      * @var \Pterodactyl\Services\Servers\StartupModificationService
 | |
|      */
 | |
|     private $modificationService;
 | |
| 
 | |
|     /**
 | |
|      * StartupController constructor.
 | |
|      */
 | |
|     public function __construct(StartupModificationService $modificationService)
 | |
|     {
 | |
|         parent::__construct();
 | |
| 
 | |
|         $this->modificationService = $modificationService;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Update the startup and environment settings for a specific server.
 | |
|      *
 | |
|      * @throws \Illuminate\Validation\ValidationException
 | |
|      * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
 | |
|      * @throws \Pterodactyl\Exceptions\Model\DataValidationException
 | |
|      * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
 | |
|      */
 | |
|     public function index(UpdateServerStartupRequest $request, Server $server): array
 | |
|     {
 | |
|         $server = $this->modificationService
 | |
|             ->setUserLevel(User::USER_LEVEL_ADMIN)
 | |
|             ->handle($server, $request->validated());
 | |
| 
 | |
|         return $this->fractal->item($server)
 | |
|             ->transformWith($this->getTransformer(ServerTransformer::class))
 | |
|             ->toArray();
 | |
|     }
 | |
| }
 |