EmailQueueRepository.php 1.3 KB

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