mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 15:16:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Requests\Admin\Api;
 | |
| 
 | |
| use App\Models\ApiKey;
 | |
| use App\Services\Acl\Api\AdminAcl;
 | |
| use App\Http\Requests\Admin\AdminFormRequest;
 | |
| 
 | |
| class StoreApplicationApiKeyRequest extends AdminFormRequest
 | |
| {
 | |
|     /**
 | |
|      * @throws \ReflectionException
 | |
|      * @throws \ReflectionException
 | |
|      */
 | |
|     public function rules(): array
 | |
|     {
 | |
|         $modelRules = ApiKey::getRules();
 | |
| 
 | |
|         return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) {
 | |
|             return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]];
 | |
|         })->merge(['memo' => $modelRules['memo']])->toArray();
 | |
|     }
 | |
| 
 | |
|     public function attributes(): array
 | |
|     {
 | |
|         return [
 | |
|             'memo' => 'Description',
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     public function getKeyPermissions(): array
 | |
|     {
 | |
|         return collect($this->validated())->filter(function ($value, $key) {
 | |
|             return substr($key, 0, strlen(AdminAcl::COLUMN_IDENTIFIER)) === AdminAcl::COLUMN_IDENTIFIER;
 | |
|         })->toArray();
 | |
|     }
 | |
| }
 | 
