AreaSettingRepository.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Mead
  5. * Date: 2019/8/6
  6. * Time: 9:16 PM
  7. */
  8. namespace App\Repositories;
  9. use App\Maps\CacheMap;
  10. use App\Models\AreaSetting;
  11. use Carbon\Carbon;
  12. use Illuminate\Support\Facades\Cache;
  13. class AreaSettingRepository extends BaseRepository
  14. {
  15. public function __construct(AreaSetting $model)
  16. {
  17. $this->model = $model;
  18. }
  19. /**
  20. * 根据area_id 获取区域配置
  21. * @param $area_id
  22. * @return mixed
  23. * User: Mead
  24. */
  25. public function byAreaId($area_id)
  26. {
  27. return $this->model->where('area_id', $area_id)->first();
  28. }
  29. /**
  30. * 根据area_id获取是否全区域可以还车
  31. * @param $area_id
  32. * @return int
  33. */
  34. public function byAreaIdGetIsWholeAreaHuanche($area_id): int
  35. {
  36. return Cache::remember(CacheMap::BY_AREA_ID_GET_IS_WHOLE_AREA_HUANCHE . $area_id, Carbon::now()->addSeconds(CacheMap::CACHE_TIME), function () use ($area_id) {
  37. return $this->model->where('area_id', $area_id)->value('is_whole_area_huanche');
  38. });
  39. }
  40. }