/ database / factories / ValidationTypeFactory.php
ValidationTypeFactory.php
 1  <?php
 2  
 3  namespace Database\Factories;
 4  
 5  use App\Models\Norm;
 6  use App\Models\Template;
 7  use App\Models\ValidationType;
 8  use Illuminate\Database\Eloquent\Factories\Factory;
 9  
10  class ValidationTypeFactory extends Factory
11  {
12      /**
13       * The name of the factory's corresponding model.
14       *
15       * @var string
16       */
17      protected $model = ValidationType::class;
18  
19      /**
20       * Define the model's default state.
21       *
22       * @return array
23       */
24      public function definition()
25      {
26          $templatesINF = Template::whereRaw("name REGEXP '^INF-0[3-5]'")->get();
27          $templateINF = $templatesINF->random();
28  
29          return [
30              'name' => fake()->name,
31              'norm_id' => Norm::inRandomOrder()->first(),
32              'template_id' => $templateINF->id,
33          ];
34      }
35  }