PunishmentOrderRepository.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. *
  4. *
  5. * @category xxx
  6. * @package PSR
  7. * @subpackage Documentation\API
  8. * @author xxx <xxx@xxx.com>
  9. * @license GPL https://xxx.com
  10. * @link https://xxx.com
  11. * @ctime: 2020/5/19 9:36
  12. */
  13. namespace App\Repositories;
  14. use App\Models\PunishmentOrder;
  15. class PunishmentOrderRepository extends BaseRepository
  16. {
  17. public function __construct(PunishmentOrder $punishmentOrder)
  18. {
  19. $this->model = $punishmentOrder;
  20. }
  21. public function getAllByUserId($user_id){
  22. return $this->model->query()->where('user_id',$user_id)->paginate();
  23. }
  24. public function getModelByNo($no){
  25. return $this->model->query()->where('no',$no)->first();
  26. }
  27. public function isPay($no){
  28. return $this->model->query()->where('no',$no)->where('pay_status',PunishmentOrder::PAY_STATUS_OK)->first();
  29. }
  30. /**
  31. * checkNoPayModel
  32. *
  33. * @param $user_id
  34. * @return bool
  35. * @author Fx
  36. *
  37. */
  38. public function checkNoPayModel($user_id){
  39. $order = $this->model
  40. ->query()
  41. ->where('user_id',$user_id)
  42. ->where('pay_status',PunishmentOrder::PAY_STATUS_NO)
  43. ->first();
  44. return empty($order);
  45. }
  46. }