StationTaskBatchTypeService.php 767 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Services;
  3. use App\Station;
  4. use App\StationTaskBatchType;
  5. use Illuminate\Support\Facades\Cache;
  6. class StationTaskBatchTypeService
  7. {
  8. /**
  9. * @param string $key
  10. * @param string $value
  11. * @return Station
  12. */
  13. public function firstByWhere(string $key,string $value):StationTaskBatchType{
  14. return Cache::remember('station_mission_batch_type_id_by_'.$key.$value, config('cache.expirations.rarelyChange'), function ()use($key,$value) {
  15. $stationMissionBatchType =StationTaskBatchType::query()->where($key, $value)->first();
  16. if(!$stationMissionBatchType)throw new \Exception("找不到 StationMissionBatchType,where $key = $value");
  17. return $stationMissionBatchType;
  18. });
  19. }
  20. }