feat: add domain management system
This commit is contained in:
37
database/factories/DomainFactory.php
Normal file
37
database/factories/DomainFactory.php
Normal 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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
19
database/seeders/DomainSeeder.php
Normal file
19
database/seeders/DomainSeeder.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user