53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\McpServer;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<McpServer>
|
|
*/
|
|
class McpServerFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->unique()->company().' MCP';
|
|
$categories = array_keys(config('mcp_servers.categories'));
|
|
|
|
return [
|
|
'name' => $name,
|
|
'slug' => Str::slug($name),
|
|
'description' => fake()->paragraph(),
|
|
'url' => fake()->url(),
|
|
'docs_url' => fake()->url(),
|
|
'logo_url' => 'https://picsum.photos/seed/'.Str::slug($name).'/200',
|
|
'category' => fake()->randomElement($categories),
|
|
'install_command' => 'npx -y '.Str::slug($name),
|
|
'config_example' => json_encode(['mcpServers' => [Str::slug($name) => ['command' => 'npx', 'args' => ['-y', Str::slug($name)]]]], JSON_PRETTY_PRINT),
|
|
'transport' => fake()->randomElement(['stdio', 'sse', 'http']),
|
|
'language' => fake()->randomElement(['TypeScript', 'Python', 'Go']),
|
|
'capabilities' => fake()->sentences(3),
|
|
'tags' => fake()->randomElements(['open-source', 'official', 'read-only', 'requires-api-key'], rand(1, 3)),
|
|
'views' => fake()->numberBetween(0, 5000),
|
|
'clicks' => fake()->numberBetween(0, 500),
|
|
'featured' => false,
|
|
'approved' => true,
|
|
];
|
|
}
|
|
|
|
public function featured(): static
|
|
{
|
|
return $this->state(fn () => ['featured' => true]);
|
|
}
|
|
|
|
public function pending(): static
|
|
{
|
|
return $this->state(fn () => ['approved' => false]);
|
|
}
|
|
}
|