BaseRepository.php 804 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Bike;
  10. class BaseRepository
  11. {
  12. protected $model;
  13. /**
  14. * 根据id获取model
  15. * @param $id
  16. * @return mixed
  17. * User: Mead
  18. */
  19. public function byIdGetModel($id)
  20. {
  21. return $this->model->where('id', $id)->first();
  22. }
  23. /**
  24. * 获取全部数据
  25. * User: Mead
  26. */
  27. public function all()
  28. {
  29. return $this->model->get();
  30. }
  31. public function byIdGetBoxNo($id)
  32. {
  33. return $this->model->where('id', $id)->value('box_no');
  34. }
  35. public function byIdGetNoRidingBoxNo($id)
  36. {
  37. return $this->model->where('id', $id)->where('is_riding', Bike::RIDING_NO)->value('box_no');
  38. }
  39. }