uuid = Str::uuid(); } public function __destruct() { // ファイルダウンロード前に削除されては困るので処理をコメントアウトしている // if (Storage::exists($this->getPath())) { // Storage::delete($this->getPath()); // } } public function getPath() { return static::DIR . "/" . $this->uuid; } public function getFullPath() { return Storage::path($this->getPath()); } public function put(string $content) { Storage::put($this->getPath(), $content); } public function append(string $content) { Storage::append($this->getPath(), $content); } public function download(string $name = "download") { return response()->download($this->getFullPath(), $name)->deleteFileAfterSend(); } }