arrayable enums, only use base ubuntu images, server controller tests, server frontend page fixes
This commit is contained in:
29
database/factories/OrganisationFactory.php
Normal file
29
database/factories/OrganisationFactory.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Organisation>
|
||||
*/
|
||||
class OrganisationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = $this->faker->company();
|
||||
$owner = User::inRandomOrder()->first() ?: User::factory()->create();
|
||||
return [
|
||||
'name' => $this->faker->company(),
|
||||
'slug' => Organisation::createUniqueSlug($name),
|
||||
'owner_id' => $owner->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
44
database/factories/ServerFactory.php
Normal file
44
database/factories/ServerFactory.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Server>
|
||||
*/
|
||||
class ServerFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->word(),
|
||||
'provider' => ServerProvider::HETZNER,
|
||||
'provider_id' => $this->faker->uuid(),
|
||||
'ipv4' => $this->faker->ipv4(),
|
||||
'ipv6' => $this->faker->ipv6(),
|
||||
'provider_status' => '',
|
||||
'status' => $this->faker->randomElement(ServerStatus::toArray()),
|
||||
'region' => '28',
|
||||
'os' => 'ubuntu',
|
||||
'plan' => '26',
|
||||
'user' => 'keystone',
|
||||
];
|
||||
}
|
||||
|
||||
public function forOrganisation(int $organisationId): static
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($organisationId) {
|
||||
return [
|
||||
'organisation_id' => $organisationId,
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace Database\Seeders;
|
||||
use App\Enums\OrganisationRole;
|
||||
use App\Enums\RepositoryType;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
@@ -31,6 +32,10 @@ class DatabaseSeeder extends Seeder
|
||||
'owner_id' => 1,
|
||||
]);
|
||||
|
||||
$servers = Server::factory(40)->forOrganisation($organisation->id)->create();
|
||||
|
||||
$organisation->servers()->saveMany($servers);
|
||||
|
||||
$organisation->members()->attach($user, ['role' => OrganisationRole::ADMIN]);
|
||||
|
||||
$application = $organisation->applications()->create([
|
||||
|
||||
Reference in New Issue
Block a user