mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +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
38 lines
906 B
PHP
38 lines
906 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Support\Str;
|
|
use App\Models\ApiKey;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class ApiKeyFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = ApiKey::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
static $token;
|
|
|
|
return [
|
|
'key_type' => ApiKey::TYPE_APPLICATION,
|
|
'identifier' => ApiKey::generateTokenIdentifier(ApiKey::TYPE_APPLICATION),
|
|
'token' => $token ?: $token = Str::random(ApiKey::KEY_LENGTH),
|
|
'allowed_ips' => [],
|
|
'permissions' => [],
|
|
'memo' => 'Test Function Key',
|
|
'created_at' => Carbon::now(),
|
|
'updated_at' => Carbon::now(),
|
|
];
|
|
}
|
|
}
|