/ database / seeders / ValidationTypeSeeder.php
ValidationTypeSeeder.php
 1  <?php
 2  
 3  namespace Database\Seeders;
 4  
 5  use App\Models\Dossier;
 6  use App\Models\Norm;
 7  use App\Models\Template;
 8  use App\Models\ValidationType;
 9  use Illuminate\Contracts\Database\Eloquent\Builder;
10  use Illuminate\Database\Console\Seeds\WithoutModelEvents;
11  use Illuminate\Database\Seeder;
12  
13  class ValidationTypeSeeder extends Seeder
14  {
15      /**
16       * Run the database seeds.
17       *
18       * @return void
19       */
20      public function run()
21      {
22          $norms = Norm::all();
23          $templatesINF = Template::whereRaw("name REGEXP '^INF-0[3-5]'")->get();
24  
25          foreach ($norms as $norm) {
26              foreach ($templatesINF as $templateINF) {
27                  $nameValidationType = explode('-', $templateINF->name)[2];
28                  ValidationType::factory()->create([
29                      'name' => $nameValidationType,
30                      'norm_id' => $norm->id,
31                      'template_id' => $templateINF->id
32                  ]);
33              }
34              /*  ValidationType::factory()->create([
35                  'name' => 'ValidacionJson',
36                  'norm_id' => $norm->id,
37                  'template_id' => Template::where('name', 'INF-12-ValidacionJSON-EN-v1')->firstOrFail()->id,
38              ]); */
39          }
40  
41          //        // TODO: Cambiar la norma y cambiar el template cuando este listo
42          //        ValidationType::factory()->create([
43          //            'name' => 'InformeValidacionSolicitudEvaluacion',
44          //            'norm_id' => $normRandom->id,
45          //            'template_id' => Template::where('name','INF-03-ValidacionParcial-EN-v1')->firstOrFail()->id,
46          //        ]);
47      }
48  }