LocationFactory.php 617 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. use Carbon\Carbon;
  3. use App\Location;
  4. use Faker\Generator as Faker;
  5. $factory->define(Location::class, function (Faker $faker) {
  6. $lat = 36.16310;
  7. $lng = 49.94950;
  8. $latArray = [];
  9. $lngArray = [];
  10. for ($i=0; $i<10; $i++){
  11. $latArray[] = $lat;
  12. $lat += 0.13733;
  13. $lngArray[] = $lng;
  14. $lng += 0.00715;
  15. }
  16. $time = Carbon::now()->subDays(rand(1, 10))->subHours(rand(8, -8));
  17. return [
  18. 'lat' => array_random($latArray),
  19. 'lng' => array_random($lngArray),
  20. 'created_at' => $time,
  21. 'updated_at' => $time,
  22. 'user_id' => null,//
  23. ];
  24. });