<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class ChargeStation extends Model
{
    public function searchChargeStationNameAttr($query, $value)
    {
        return $value ? $query->where('charge_station_name', 'like', '%'.$value.'%') : '';
    }

    public function searchStationTypeAttr($query, $value)
    {
        return $value ? $query->where('station_type', '=', $value) : '';
    }

    public function searchCityAttr($query, $value)
    {
        return $value ? $query->where('city', 'like', '%'.$value.'%') : '';
    }

    public function searchAreaAttr($query, $value)
    {
        return $value ? $query->where('area', 'like', '%'.$value.'%') : '';
    }

    public function searchStreetAttr($query, $value)
    {
        return $value ? $query->where('street', 'like', '%'.$value.'%') : '';
    }

    public function searchAddressAttr($query, $value)
    {
        return $value ? $query->where('address', 'like', '%'.$value.'%') : '';
    }

    public function searchPriceAttr($query, $value)
    {
        return $value ? $query->where('price', 'between', [intval($value),intval($value)+1]) : '';
    }

}
