mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 06:46:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Controllers\Api\Client\Servers;
 | |
| 
 | |
| use App\Models\Server;
 | |
| use App\Transformers\Api\Client\ServerTransformer;
 | |
| use App\Services\Servers\GetUserPermissionsService;
 | |
| use App\Http\Controllers\Api\Client\ClientApiController;
 | |
| use App\Http\Requests\Api\Client\Servers\GetServerRequest;
 | |
| 
 | |
| class ServerController extends ClientApiController
 | |
| {
 | |
|     /**
 | |
|      * ServerController constructor.
 | |
|      */
 | |
|     public function __construct(private GetUserPermissionsService $permissionsService)
 | |
|     {
 | |
|         parent::__construct();
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Transform an individual server into a response that can be consumed by a
 | |
|      * client using the API.
 | |
|      */
 | |
|     public function index(GetServerRequest $request, Server $server): array
 | |
|     {
 | |
|         return $this->fractal->item($server)
 | |
|             ->transformWith($this->getTransformer(ServerTransformer::class))
 | |
|             ->addMeta([
 | |
|                 'is_server_owner' => $request->user()->id === $server->owner_id,
 | |
|                 'user_permissions' => $this->permissionsService->handle($server, $request->user()),
 | |
|             ])
 | |
|             ->toArray();
 | |
|     }
 | |
| }
 | 
