SmmPost.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ]);
  30. $model->save();
  31. return $model->id;
  32. }
  33. /*
  34. * 找出状态 0 的数据
  35. */
  36. public static function getWaitPost()
  37. {
  38. $model = new Model();
  39. $model = $model->where('status',0)->get();
  40. return $model;
  41. }
  42. public static function getPostById($id)
  43. {
  44. $model = new Model();
  45. $model = $model->where('id',$id)->first();
  46. return $model;
  47. }
  48. }