File manager - Edit - /var/www/html/portal/database/seeders/SugeaSeeder.php
Back
<?php namespace Database\Seeders; use Illuminate\Database\Seeder; use App\Models\Structure; use Illuminate\Support\Str; class SugeaSeeder extends Seeder { /** * Run the database seeds. */ public function run(): void { // Verificar se SUGEA já existe $sugea = Structure::where('abbreviation', 'SUGEA') ->orWhere('name', 'like', '%Superintendência De Gestão e Articulação%') ->orWhere('name', 'like', '%SUGEA%') ->first(); if ($sugea) { $this->command->info('SUGEA já existe no banco: ' . $sugea->name); return; } // Buscar a Secretaria de Proteção e Defesa Civil (SPDC) $spdc = Structure::where('abbreviation', 'SPDC') ->orWhere('name', 'like', '%Secretaria de Proteção e Defesa Civil%') ->first(); if (!$spdc) { $this->command->error('❌ Secretaria de Proteção e Defesa Civil (SPDC) não encontrada no banco!'); $this->command->warn('💡 Execute primeiro o seeder ou crie a SPDC manualmente antes de criar a SUGEA.'); return; } // Criar Superintendência De Gestão e Articulação (SUGEA) Structure::create([ 'id' => Str::uuid(), 'structure_id' => $spdc->id, // Relaciona com a SPDC 'type' => 'SUPERINTENDENCIA', 'name' => 'Superintendência De Gestão e Articulação', 'abbreviation' => 'SUGEA', 'slug' => 'superintendencia-de-gestao-e-articulacao', 'address' => $spdc->address ?? 'Angra dos Reis - RJ', // Usa o endereço da SPDC como padrão 'phoneNumber' => $spdc->phoneNumber ?? '(24) 3377-6046', 'email1' => $spdc->email1 ?? 'defesacivil@angra.rj.gov.br', 'pronunciation' => 'SUPERINTENDENTE', 'manager' => 'Superintendente', 'status' => 'ATIVADO', ]); $this->command->info('✅ Superintendência De Gestão e Articulação (SUGEA) criada com sucesso!'); $this->command->info(' Vinculada à: ' . $spdc->name . ' (' . $spdc->abbreviation . ')'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.16 |
proxy
|
phpinfo
|
Settings