File: /var/www/api_matriculas/database/seeders/PeriodSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PeriodSeeder extends Seeder
{
public function run(): void
{
$periods = [
[
'period_year' => 2026,
'period' => 'Periodo Académico 2026',
'start_date' => '2026-01-01',
'end_date' => '2026-12-31',
'status' => 1,
'created_at' => now(),
'updated_at' => now(),
],
];
foreach ($periods as $period) {
// Insertar/actualizar periodo
DB::table('periods')->updateOrInsert(
['period_year' => $period['period_year']],
$period
);
// Obtener ID real
$periodRow = DB::table('periods')->where('period_year', $period['period_year'])->first();
// Definir segmentos del proceso de matrícula
$year = $period['period_year'] - 1;
$segments = [
[
'description' => 'Matrícula Regular',
'start_date' => "{$year}-10-01",
'end_date' => "{$period['period_year']}-03-01",
'observacion' => 'Pago de colegiatura anticipada con 2% de descuento si paga en 1 cuota',
],
[
'description' => 'Matrícula Excepcional',
'start_date' => "{$year}-11-12",
'end_date' => "{$year}-11-14",
'observacion' => 'Recargo de tarifa. Pago de colegiatura excepcional con recargo (%)',
],
[
'description' => 'Condición Académica Especial (CAE)',
'start_date' => "{$year}-12-10", // día referencial en diciembre
'end_date' => "{$year}-12-10",
'observacion' => 'Proceso CAE, sin recargo por colegiatura excepcional',
],
];
foreach ($segments as $seg) {
DB::table('enrollment_periods')->updateOrInsert(
[
'period_id' => $periodRow->id,
'description' => $seg['description']
],
[
'start_date' => $seg['start_date'],
'end_date' => $seg['end_date'],
'status' => 1,
'created_at' => now(),
'updated_at' => now(),
]
);
}
}
$this->command->info('✅ Periodos y segmentos de matrícula creados correctamente.');
}
}