/ database / factories / TOEFactory.php
TOEFactory.php
 1  <?php
 2  
 3  namespace Database\Factories;
 4  
 5  use App\Enums\SectorialDimensionsEnum;
 6  use App\Enums\TechnologicalDimensionsEnum;
 7  use App\Enums\TOEProductSystemEnum;
 8  use App\Enums\UsageDimensionsEnum;
 9  use App\Models\ContactInfo;
10  use App\Models\Country;
11  use App\Models\Entity;
12  use App\Models\TOE;
13  use App\Models\TOEType;
14  use Illuminate\Database\Eloquent\Factories\Factory;
15  
16  class TOEFactory extends Factory
17  {
18      /**
19       * The name of the factory's corresponding model.
20       *
21       * @var string
22       */
23      protected $model = TOE::class;
24  
25      /**
26       * Define the model's default state.
27       *
28       * @return array
29       */
30      public function definition()
31      {
32          return [
33              'name' => $this->faker->name(),
34              'evaluation_target' => $this->faker->sentence(2),
35              'evaluation_scope' => $this->faker->sentence(2),
36              'commercial_name' => $this->faker->sentence(2),
37              'sectorial_dimensions' => $this->faker->randomElements(SectorialDimensionsEnum::toArray(), rand(1, SectorialDimensionsEnum::getNumber())),
38              'usage_dimension' => $this->faker->randomElements(UsageDimensionsEnum::toArray()),
39              'technological_dimensions' => $this->faker->randomElements(TechnologicalDimensionsEnum::toArray(), rand(1, TechnologicalDimensionsEnum::getNumber())),
40              'cyber_security_info_url' => $this->faker->url(),
41              'guidance_url' => $this->faker->url(),
42              'period_security_support' => $this->faker->numberBetween(1, 100),
43              'provider_contact_vulnerability_url' => $this->faker->url(),
44              'vulnerability_notifications' => $this->faker->email(),
45              'publicly_disclosed_url' => $this->faker->url(),
46              'description' => $this->faker->paragraph(),
47              'company_id' => Entity::factory(state: ['entity_type_id' => 3])->has(ContactInfo::factory()),
48              'version' => '1',
49              'alias' => $this->faker->sentence(2),
50              'country_id' => Country::all()->random()->id,
51              'is_active' => true,
52              'spdx_path' => 'test_files/toe.spdx',
53              'is_certified' => false,
54              'development_address' => $this->faker->address(),
55              'product_system' => collect(TOEProductSystemEnum::toLabels())->random(),
56          ];
57      }
58  }