<?php


namespace App\Services;


use App\Station;
use App\StationTaskBatchType;
use Illuminate\Support\Facades\Cache;
use App\Traits\ServiceAppAop;


class StationTaskBatchTypeService
{
    use ServiceAppAop;
    protected $modelClass=StationTaskBatchType::class;
    /**
     * @param string $key
     * @param string $value
     * @return Station
     */
    public function firstByWhere(string $key,string $value):StationTaskBatchType{
        return Cache::remember('station_mission_batch_type_id_by_'.$key.$value, config('cache.expirations.rarelyChange'), function ()use($key,$value) {
            $stationMissionBatchType =StationTaskBatchType::query()->where($key, $value)->first();
            if(!$stationMissionBatchType)throw new \Exception("找不到 StationMissionBatchType,where $key = $value");
            return $stationMissionBatchType;
        });
    }
}
