DeleteCommentPipeline.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Jobs\GroupsPipeline;
  3. use App\Util\Media\Image;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Queue\SerializesModels;
  9. use App\Models\Group;
  10. use App\Models\GroupComment;
  11. use App\Models\GroupPost;
  12. use App\Models\GroupHashtag;
  13. use App\Models\GroupPostHashtag;
  14. use App\Util\Lexer\Autolink;
  15. use App\Util\Lexer\Extractor;
  16. use DB;
  17. class DeleteCommentPipeline implements ShouldQueue
  18. {
  19. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  20. protected $parent;
  21. protected $status;
  22. /**
  23. * Delete the job if its models no longer exist.
  24. *
  25. * @var bool
  26. */
  27. public $deleteWhenMissingModels = true;
  28. /**
  29. * Create a new job instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct($parent, $status)
  34. {
  35. $this->parent = $parent;
  36. $this->status = $status;
  37. }
  38. /**
  39. * Execute the job.
  40. *
  41. * @return void
  42. */
  43. public function handle()
  44. {
  45. $parent = $this->parent;
  46. $parent->reply_count = GroupComment::whereStatusId($parent->id)->count();
  47. $parent->save();
  48. return;
  49. }
  50. }