mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00

* use RESOURCE_NAME for requests * use RESOURCE_NAME for transformers * add permissions field to api key * add migration for new permissions field * update tests * remove debug log * set column type to "json" * remove default attribute to fix tests * fix default value for permissions * fix after merge * fix after merge * allow to "register" custom permissions * add "role" to default resource names * fix after merge * fix phpstan * fix migrations
40 lines
778 B
PHP
40 lines
778 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Api;
|
|
|
|
use App\Models\ApiKey;
|
|
use App\Http\Requests\Admin\AdminFormRequest;
|
|
|
|
class StoreApplicationApiKeyRequest extends AdminFormRequest
|
|
{
|
|
/**
|
|
* @throws \ReflectionException
|
|
* @throws \ReflectionException
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$modelRules = ApiKey::getRules();
|
|
|
|
$rules = [
|
|
'memo' => $modelRules['memo'],
|
|
'permissions' => $modelRules['permissions'],
|
|
];
|
|
|
|
return $rules;
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'memo' => 'Description',
|
|
];
|
|
}
|
|
|
|
public function getKeyPermissions(): array
|
|
{
|
|
$data = $this->validated();
|
|
|
|
return array_keys($data['permissions']);
|
|
}
|
|
}
|