feat: add domain management system

This commit is contained in:
idevakk
2025-11-15 11:40:04 -08:00
parent d9291f06eb
commit 466a370f28
12 changed files with 508 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Domain>
*/
class DomainFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$domain = $this->faker->unique()->domainName();
$startDate = $this->faker->optional()->dateTimeBetween('-6 months', 'now');
$endDate = $startDate ?
$this->faker->optional()->dateTimeBetween($startDate, '+1 year') :
$this->faker->optional()->dateTimeBetween('now', '+1 year');
return [
'name' => $domain,
'is_active' => true,
'daily_mailbox_limit' => $this->faker->numberBetween(50, 500),
'domain_type' => $this->faker->randomElement(['disposable', 'temporary', 'custom']),
'provider_type' => $this->faker->randomElement(['internal', 'external', 'partner']),
'starts_at' => $startDate,
'ends_at' => $endDate,
'last_used_at' => $this->faker->optional()->dateTimeBetween('-1 month', 'now'),
'checked_at' => $this->faker->optional()->dateTimeBetween('-1 week', 'now'),
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('domains', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->boolean('is_active')->default(true);
$table->integer('daily_mailbox_limit')->default(100);
$table->string('domain_type')->nullable();
$table->string('provider_type')->nullable();
$table->timestamp('starts_at')->nullable();
$table->timestamp('ends_at')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('checked_at')->nullable();
$table->softDeletes();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('domains');
}
};

View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\Domain;
use Illuminate\Database\Seeder;
class DomainSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Domain::factory()
->count(20)
->create();
}
}