You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

2 years ago
  1. <?php
  2. namespace Database\Factories\Documents;
  3. use App\Documents\FingerPrintDocument;
  4. use App\Documents\UserDocument;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. use Illuminate\Support\Arr;
  7. use Illuminate\Support\Str;
  8. use Jenssegers\Agent\Agent;
  9. class FingerPrintDocumentFactory extends Factory
  10. {
  11. protected $model = FingerPrintDocument::class;
  12. public function definition()
  13. {
  14. $browsers = [
  15. $this->faker->firefox,
  16. $this->faker->chrome,
  17. $this->faker->opera,
  18. $this->faker->safari,
  19. ];
  20. $detector = new Agent();
  21. return [
  22. '_id' => app('nextId'),
  23. 'user_id' => '',
  24. 'token' => Str::random(60),
  25. 'agent' => app()->environment("testing")? 'Firefox': $detector->browser(Arr::random($browsers)),
  26. 'os' => app()->environment("testing")? 'Ubuntu': $detector->platform(Arr::random($browsers)),
  27. 'ip' => $this->faker->ipv4,
  28. 'city' => "Tehran",
  29. 'country' => "Iran",
  30. 'expires_at' => $this->faker->dateTimeBetween('+1 day', ' +6 month')->format('Y-m-d'),
  31. ];
  32. }
  33. }