feat: add seeder command and configuration for database seeding

This commit is contained in:
Andras Bacsai
2024-12-11 21:31:12 +01:00
parent a7330fe52b
commit d2ff8c6521
3 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Seeder extends Command
{
protected $signature = 'start:seeder';
protected $description = 'Start Seeder';
public function handle()
{
if (config('constants.seeder.is_seeder_enabled')) {
$this->info('Seeder is enabled on this server.');
$this->call('db:seed', ['--class' => 'ProductionSeeder', '--force' => true]);
exit(0);
} else {
$this->info('Seeder is disabled on this server.');
exit(0);
}
}
}

View File

@@ -37,6 +37,10 @@ return [
'is_migration_enabled' => env('MIGRATION_ENABLED', true), 'is_migration_enabled' => env('MIGRATION_ENABLED', true),
], ],
'seeder' => [
'is_seeder_enabled' => env('SEEDER_ENABLED', true),
],
'horizon' => [ 'horizon' => [
'is_horizon_enabled' => env('HORIZON_ENABLED', true), 'is_horizon_enabled' => env('HORIZON_ENABLED', true),
'is_scheduler_enabled' => env('SCHEDULER_ENABLED', true), 'is_scheduler_enabled' => env('SCHEDULER_ENABLED', true),

View File

@@ -6,10 +6,7 @@ cd /var/www/html
foreground { foreground {
php php
artisan artisan
db:seed start:seeder
--class
ProductionSeeder
--force
} }