= 4" Eloquen...">

MySQL Implementation Spatial Functions Using Laravel Eloquent ORM

Request 1:

"SELECT * from search_table WHERE column> = 4"

Eloquent implementation of ORM 'Query1'

$searchResults = SearchTempTable::select(*);

$searchResults = $searchResults->where('column', '>=', 4);

      

Request 2:

"SELECT * FROM search_table WHERE ST_Intersects (column, geomfromtext ('POLYGON (($ point1X $ point1Y, $ point2X $ point2Y, $ point3X $ point3Y, $ point4X $ point4Y, $ point1X $ point1Y))'))"

How "Query 2" can be implemented in Eloquent ORM?

+3


source to share


1 answer


For this, only the operator will work raw

.



$bindings = [$point1X, $point1Y, ... ];

SearchTempTable::whereRaw(
 "ST_Intersects(column, geomfromtext( 'POLYGON((? ?, ? ?, ? ?, ? ?, ? ?))' ))",
  $bindings
)->get();

      

+4


source







All Articles