LocationFactory.php 709 B

1234567891011121314151617181920212223242526272829
  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' => Carbon::now()->subDays(rand(1, 10))->subHours(rand(8, -8)),
  21. 'created_at' => $time,
  22. 'updated_at' => $time,
  23. 'user_id' => null,//
  24. ];
  25. });