<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class District extends Model
{
    protected $geometry = ['boundaries'];

    /**
     * Select geometrical attributes as text from database.
     *
     * @var bool
     */
    protected $geometryAsText = true;



//    public function newQuery($excludeDeleted = true)
//    {
//        if (!empty($this->geometry) && $this->geometryAsText === true)
//        {
//            $raw = '';
//            foreach ($this->geometry as $column)
//            {
//                $raw .= 'AsText(`' . $this->table . '`.`' . $column . '`) as `' . $column . '`, ';
//            }
//            $raw = substr($raw, 0, -2);
//
//            return parent::newQuery($excludeDeleted)->addSelect('*', DB::raw($raw));
//        }
//        return parent::newQuery($excludeDeleted);
//    }
}
