/ database / factories / DocumentFactory.php
DocumentFactory.php
 1  <?php
 2  
 3  namespace Database\Factories;
 4  
 5  use App\Models\Document;
 6  use App\Models\DocumentType;
 7  use App\Models\Dossier;
 8  use Illuminate\Database\Eloquent\Factories\Factory;
 9  
10  class DocumentFactory extends Factory
11  {
12      /**
13       * The name of the factory's corresponding model.
14       *
15       * @var string
16       */
17      protected $model = Document::class;
18  
19      /**
20       * Define the model's default state.
21       *
22       * @return array
23       */
24      public function definition()
25      {
26          $type = DocumentType::all()->random();
27  
28          return [
29              'type_id' => $type->id,
30              'number' => count($type->documents) + 1,
31              'name' => $this->faker->word,
32              'from' => $this->faker->word,
33              'description' => $this->faker->sentence,
34              //'approved' => 0,
35              'original_id' => null,
36              'head_id' => null,
37              //'approved_by' => null,
38              'external_version' => '1.337',
39              'signed_at' => $this->faker->date,
40              'dossier_id' => Dossier::factory()->create(),
41          ];
42      }
43  }