How to handle mysql spatial datatypes in eloquent ORM?, This include how to create migration, insert spatial data and performing spatial query's. If there is not actual solutions exists, is there any workarounds?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
It is available to use https://github.com/grimzy/laravel-mysql-spatial
you may use:
then you are able to run queries on the 'location' field.
to store model you may use:
to retrieving a model you should use:
A workaround I have implemented a while ago is to have a latitude and longitude fields on the model with the following validations (see Validator class):
The magic comes on the boot method of the model, which sets the correct value of the spatial point field:
About migrations, like @jhmilan says you can always use the Schema::create and DB::statement methods to customize the migration.