StationTaskBatchTypeService.php 876 B

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