LocationFactory.php 558 B

1234567891011121314151617181920212223242526
  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. return [
  17. 'lat' => array_random($latArray),
  18. 'lng' => array_random($lngArray),
  19. 'created_at' => Carbon::now()->subDays(rand(1, 10)),
  20. 'user_id' => null,//
  21. ];
  22. });