AreaRepository.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\Models\Area;
  10. use Illuminate\Support\Facades\Redis;
  11. class AreaRepository extends BaseRepository
  12. {
  13. private static $filed = [
  14. 'name',
  15. 'area_fence',
  16. 'customer_service_time',
  17. 'customer_service_phone',
  18. 'status'
  19. ];
  20. public function __construct(Area $area)
  21. {
  22. $this->model = $area;
  23. }
  24. public function byIdGetModelRedis($id)
  25. {
  26. $area = Redis::connection()->hget(Area::REDIS_AREAS_TAG, $id);
  27. if ($area) {
  28. $area = unserialize($area);
  29. $area['area_fence'] = js2php($area['area_fence']);
  30. $area['area_centre'] = js2php($area['area_centre']);
  31. $area['area_fushe_fence'] = js2php($area['area_fushe_fence']);
  32. return $area;
  33. }
  34. return false;
  35. }
  36. public function all()
  37. {
  38. return $this->model->active()->get();
  39. }
  40. public function getFieldAreas()
  41. {
  42. return $this->model->select(self::$filed)->get();
  43. }
  44. }