mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 10:06:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Requests\Api\Application\Servers;
 | |
| 
 | |
| use App\Http\Requests\Api\Application\ApplicationApiRequest;
 | |
| use App\Models\Server;
 | |
| use App\Services\Acl\Api\AdminAcl;
 | |
| 
 | |
| class UpdateServerStartupRequest extends ApplicationApiRequest
 | |
| {
 | |
|     protected ?string $resource = Server::RESOURCE_NAME;
 | |
| 
 | |
|     protected int $permission = AdminAcl::WRITE;
 | |
| 
 | |
|     /**
 | |
|      * Validation rules to run the input against.
 | |
|      */
 | |
|     public function rules(): array
 | |
|     {
 | |
|         $rules = $this->route() ? Server::getRulesForUpdate($this->parameter('server', Server::class)) : Server::getRules();
 | |
| 
 | |
|         return [
 | |
|             'startup' => 'sometimes|string',
 | |
|             'environment' => 'present|array',
 | |
|             'egg' => $rules['egg_id'],
 | |
|             'image' => 'sometimes|string',
 | |
|             'skip_scripts' => 'present|boolean',
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Return the validated data in a format that is expected by the service.
 | |
|      *
 | |
|      * @return array<string, mixed>
 | |
|      */
 | |
|     public function validated($key = null, $default = null): array
 | |
|     {
 | |
|         $data = parent::validated();
 | |
| 
 | |
|         return collect($data)->only(['startup', 'environment', 'skip_scripts'])->merge([
 | |
|             'egg_id' => array_get($data, 'egg'),
 | |
|             'docker_image' => array_get($data, 'image'),
 | |
|         ])->toArray();
 | |
|     }
 | |
| }
 | 
