grimzy/laravel-mysql-spatial

View on GitHub
src/Eloquent/BaseBuilder.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php

namespace Grimzy\LaravelMysqlSpatial\Eloquent;

use Illuminate\Database\Query\Builder as QueryBuilder;

class BaseBuilder extends QueryBuilder
{
    public function cleanBindings(array $bindings)
    {
        $spatialBindings = [];
        foreach ($bindings as &$binding) {
            if ($binding instanceof SpatialExpression) {
                $spatialBindings[] = $binding->getSpatialValue();
                $spatialBindings[] = $binding->getSrid();
            } else {
                $spatialBindings[] = $binding;
            }
        }

        return parent::cleanBindings($spatialBindings);
    }
}