領収証発行サービス
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
886B

  1. <?php
  2. namespace App\Jobs\File;
  3. use App\Codes\QueueName;
  4. use App\Files\TmpFile;
  5. use App\Jobs\BaseJob;
  6. use Illuminate\Support\Facades\Storage;
  7. class DeleteFile extends BaseJob
  8. {
  9. private string $fileId;
  10. private string $storagePath;
  11. /**
  12. * Create a new job instance.
  13. *
  14. * @return void
  15. */
  16. public function __construct(
  17. private TmpFile $file,
  18. ) {
  19. $this->onQueue(QueueName::JOB->value);
  20. $this->fileId = $file->getId();
  21. $this->storagePath = $file->getPath();
  22. logger("FILE削除JOB登録:" . $this->storagePath);
  23. }
  24. /**
  25. * Execute the job.
  26. *
  27. * @return void
  28. */
  29. public function handle()
  30. {
  31. if (Storage::exists($this->storagePath)) {
  32. Storage::delete($this->storagePath);
  33. info(sprintf("ファイル削除:%s ", $this->storagePath));
  34. }
  35. }
  36. }