<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

/**
 * @mixin \think\Model
 */
class ChargeOrder extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';

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

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

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

    public function searchChargeDateAttr($query, $value)
    {
        return $value ? $query->whereTime('charge_date', '>=', $value) : '';
    }

    public function searchStatusAttr($query, $value)
    {
        return $value ? $query->where('status', '=', "'".$value."'") : '';
    }
}
