SmmPost.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App\Distributor\Repositories;
  3. use App\Models\SmmPost as Model;
  4. use Dcat\Admin\Repositories\EloquentRepository;
  5. class SmmPost extends EloquentRepository
  6. {
  7. /**
  8. * Model.
  9. *
  10. * @var string
  11. */
  12. protected $eloquentClass = Model::class;
  13. /*
  14. * 插入数据
  15. */
  16. public static function create($post,$sendTime,$imageVideoUrl)
  17. {
  18. $model = new Model();
  19. // $model->send_type = $post['send_type'];
  20. $model->send_time = $sendTime;
  21. $model->message = $post['message'];
  22. $model->post_type = $post['post_type'];
  23. $model->account_ids = implode(',',$post['account_ids']);
  24. $model->image_video_url = $imageVideoUrl;
  25. $model->status = 0;
  26. $model->dist_id = getDistributorId();
  27. $model->backup_field1 = json_encode([
  28. 'youtube_category' => $post['youtube_category'],
  29. 'yutube_title' => $post['yutube_title'],
  30. ]);
  31. $model->save();
  32. return $model->id;
  33. }
  34. /*
  35. * 找出状态 0 的数据
  36. */
  37. public static function getWaitPost()
  38. {
  39. $model = new Model();
  40. $model = $model->where('status',0)->get();
  41. return $model;
  42. }
  43. public static function getOssUploadPost()
  44. {
  45. $model = new Model();
  46. $model = $model->where('oss_upload',0)->get();
  47. return $model;
  48. }
  49. public static function getOssUploadingPostCount()
  50. {
  51. $model = new Model();
  52. $count = $model->where('oss_upload',1)->count();
  53. return $count;
  54. }
  55. public static function getPostById($id)
  56. {
  57. $model = new Model();
  58. $model = $model->where('id',$id)->first();
  59. return $model;
  60. }
  61. }