SmsQueueRepository.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\SmsQueue;
  4. use Prettus\Repository\Eloquent\BaseRepository;
  5. use Prettus\Repository\Criteria\RequestCriteria;
  6. /**
  7. * Class SmsQueueRepository.
  8. *
  9. * @package namespace App\Repositories;
  10. */
  11. class SmsQueueRepository extends BaseRepository
  12. {
  13. /**
  14. * Specify Model class name
  15. *
  16. * @return string
  17. */
  18. public function model()
  19. {
  20. return SmsQueue::class;
  21. }
  22. /**
  23. * Boot up the repository, pushing criteria
  24. */
  25. public function boot()
  26. {
  27. $this->pushCriteria(app(RequestCriteria::class));
  28. }
  29. /**
  30. * @param $template
  31. * @param $mobile
  32. * @param int $utype
  33. * @param int $sender_id
  34. * @param int $batch_id
  35. * @return SmsQueue
  36. * @throws \Prettus\Validator\Exceptions\ValidatorException
  37. */
  38. public function createRecord($template, $mobile, $utype = 0, $sender_id = 0, $batch_id = 0)
  39. {
  40. $attribute['batch_id']=$batch_id;
  41. $attribute['utype']=$utype;
  42. $attribute['sender_id']=$sender_id;
  43. $attribute['s_number']=$mobile;
  44. $attribute['s_body']=$template->value;
  45. $attribute['sms_id']=$template->id;
  46. return $this->create($attribute);
  47. }
  48. public function saveRecord($id, $status, $message = "")
  49. {
  50. $attribute['s_status']=$status;
  51. $attribute['s_sendtime']=time();
  52. $attribute['error_message']=$message;
  53. $this->update($attribute, $id);
  54. }
  55. }