How to make fake coordinates of point column through factory?
P粉933003350
P粉933003350 2024-02-04 00:11:30
0
1
325

I tried making fake data via a factory containing the point column.

Coordinate columns in migration:

$table->point('coordinate');

I tried it at the factory:

'coordinate' => DB::raw("Point(" . fake()->latitude() . " " . fake()->longitude() . ")"),

'coordinate' => "Point(" . fake()->latitude() . " " . fake()->longitude() . ")",

'coordinate' => fake()->latitude() . " " . fake()->longitude(),

'coordinate' => [fake()->latitude(), fake()->longitude()],

Is there a way to fake the coordinates with the point column or use raw sql in the factory?

P粉933003350
P粉933003350

reply all(1)
P粉042455250

I think you can try using ST_GeomFromText

'coordinate' => DB::raw("ST_GeomFromText('POINT(" . $this->faker->latitude . " " . $this->faker->longitude . ")')"),
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!