create network if doesn't already exist on server, wip test
This commit is contained in:
35
database/factories/ProviderFactory.php
Normal file
35
database/factories/ProviderFactory.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ProviderType;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Provider>
|
||||
*/
|
||||
class ProviderFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'keystone',
|
||||
'type' => $this->faker->randomElement([
|
||||
ProviderType::HETZNER,
|
||||
]),
|
||||
'token' => $this->faker->uuid(),
|
||||
];
|
||||
}
|
||||
|
||||
public function forOrganisation($organisationId): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'organisation_id' => $organisationId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ class ServerFactory extends Factory
|
||||
'name' => $this->faker->word(),
|
||||
'ipv4' => $this->faker->ipv4(),
|
||||
'ipv6' => $this->faker->ipv6(),
|
||||
'private_ip' => $this->faker->ipv4(),
|
||||
'provider_status' => '',
|
||||
'status' => $this->faker->randomElement(ServerStatus::toArray()),
|
||||
'region' => '28',
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignIdFor(Organisation::class);
|
||||
$table->foreignIdFor(Network::class, 'external_network_id');
|
||||
$table->foreignIdFor(Network::class, 'internal_network_id');
|
||||
$table->foreignIdFor(Network::class, 'internal_network_id')->nullable();
|
||||
$table->foreignIdFor(Provider::class);
|
||||
$table->string('external_id')->nullable();
|
||||
$table->string('name');
|
||||
|
||||
Reference in New Issue
Block a user