Phaza\LaravelPostgis\Eloquent\PostgisTrait::performInsert PHP Method

performInsert() protected method

protected performInsert ( Builder $query, array $options = [] )
$query Illuminate\Database\Eloquent\Builder
$options array
    protected function performInsert(EloquentBuilder $query, array $options = [])
    {
        foreach ($this->attributes as $key => $value) {
            if ($value instanceof GeometryInterface && !$value instanceof GeometryCollection) {
                $this->geometries[$key] = $value;
                //Preserve the geometry objects prior to the insert
                $this->attributes[$key] = $this->getConnection()->raw(sprintf("ST_GeogFromText('%s')", $value->toWKT()));
            } else {
                if ($value instanceof GeometryInterface && $value instanceof GeometryCollection) {
                    $this->geometries[$key] = $value;
                    //Preserve the geometry objects prior to the insert
                    $this->attributes[$key] = $this->getConnection()->raw(sprintf("ST_GeomFromText('%s', 4326)", $value->toWKT()));
                }
            }
        }
        $insert = parent::performInsert($query, $options);
        foreach ($this->geometries as $key => $value) {
            $this->attributes[$key] = $value;
            //Retrieve the geometry objects so they can be used in the model
        }
        return $insert;
        //Return the result of the parent insert
    }