mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 08:06:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			903 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			903 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Requests\Api\Client\Servers;
 | |
| 
 | |
| use App\Models\Permission;
 | |
| use App\Http\Requests\Api\Client\ClientApiRequest;
 | |
| 
 | |
| class SendPowerRequest extends ClientApiRequest
 | |
| {
 | |
|     /**
 | |
|      * Determine if the user has permission to send a power command to a server.
 | |
|      */
 | |
|     public function permission(): string
 | |
|     {
 | |
|         switch ($this->input('signal')) {
 | |
|             case 'start':
 | |
|                 return Permission::ACTION_CONTROL_START;
 | |
|             case 'stop':
 | |
|             case 'kill':
 | |
|                 return Permission::ACTION_CONTROL_STOP;
 | |
|             case 'restart':
 | |
|                 return Permission::ACTION_CONTROL_RESTART;
 | |
|         }
 | |
| 
 | |
|         return '__invalid';
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Rules to validate this request against.
 | |
|      */
 | |
|     public function rules(): array
 | |
|     {
 | |
|         return [
 | |
|             'signal' => 'required|string|in:start,stop,restart,kill',
 | |
|         ];
 | |
|     }
 | |
| }
 | 
