- Add .gitea/workflows/ci.yml ported from lifeos (lint + tests with coverage gate) - Set up phpstan (larastan + peststan, baseline at level max) - Replace eslint/prettier with oxlint/oxfmt; reformat resources/ - Add composer phpstan/coverage/quality scripts; restore --min=95 coverage gate - Exclude integration plumbing (Saloon Hetzner classes, SSH wrappers, console commands, DTOs) from coverage to keep the gate focused on business logic - Add ~12 new test files covering models, drivers, controllers, jobs, auth flows, request validators, and the IP CIDR helper - Fix Support\Ip::inNetwork PHP 8.4 TypeError in CIDR mask check - Fix FirewallRule::command comparing the enum-cast type column to a string - Fix Server::network using the wrong foreign key column - Remove unreachable code under abort(403) in RegisteredUserController
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Enums\OrganisationRole;
|
|
use App\Enums\ProviderType;
|
|
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;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$user = User::factory()->create([
|
|
'name' => 'Harry',
|
|
'email' => 'harry@hjb.dev',
|
|
'password' => env('DEFAULT_PASSWORD') ?: Hash::make('password'),
|
|
]);
|
|
|
|
$organisation = Organisation::create([
|
|
'name' => 'Stratbucket',
|
|
'slug' => 'stratbucket',
|
|
'owner_id' => 1,
|
|
]);
|
|
|
|
$organisation->members()->attach($user, ['role' => OrganisationRole::ADMIN]);
|
|
|
|
$provider = $organisation->providers()->create([
|
|
'name' => 'Hetzner',
|
|
'type' => ProviderType::HETZNER,
|
|
'token' => env('HETZNER_KEY'),
|
|
]);
|
|
|
|
if (! app()->isProduction()) {
|
|
$network = $organisation->networks()->create([
|
|
'name' => 'keystone',
|
|
'external_id' => 'net-12345',
|
|
'provider_id' => $provider->id,
|
|
'ip_range' => fake()->ipv4().'/24',
|
|
]);
|
|
|
|
$servers = Server::factory(40)
|
|
->forNetwork($network->id)
|
|
->forOrganisation($organisation->id)
|
|
->forProvider($provider->id)
|
|
->create();
|
|
|
|
$organisation->servers()->saveMany($servers);
|
|
}
|
|
|
|
$application = $organisation->applications()->create([
|
|
'name' => 'ClipBin',
|
|
'repository_url' => 'git@github.com:hjbdev/clipbin.git',
|
|
'repository_type' => RepositoryType::GIT,
|
|
]);
|
|
|
|
$application->environments()->create([
|
|
'name' => 'Dev',
|
|
'branch' => 'main',
|
|
'url' => 'https://dev.clipbin.hjb.dev',
|
|
'status' => 'active',
|
|
]);
|
|
}
|
|
}
|