StationTaskBatchTypeService.php 775 B

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