Skip to content

Commit

Permalink
save on transform
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Nov 13, 2024
1 parent d1dcd47 commit de36899
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Concerns/InteractWithFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Elegantly\Media\Helpers\File;
use Elegantly\Media\TemporaryDirectory;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\File as HttpFile;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
Expand All @@ -28,6 +29,8 @@
* @property ?float $aspect_ratio
* @property ?float $duration
* @property ?MediaType $type
*
* @mixin Model
*/
trait InteractWithFiles
{
Expand Down Expand Up @@ -90,6 +93,9 @@ public function deleteFile(): bool
return true;
}

/**
* @return ?string The new file path on success, null on failure
*/
public function putFile(
string $disk,
string $destination,
Expand Down Expand Up @@ -129,6 +135,9 @@ public function putFile(
return $path;
}

/**
* @return ?string The new file path on success, null on failure
*/
public function copyFileTo(
string|Filesystem $disk,
string $path,
Expand All @@ -149,6 +158,9 @@ public function copyFileTo(
return $result ? $path : null;
}

/**
* @return ?string The new file path on success, null on failure
*/
public function moveFileTo(
string $disk,
string $path,
Expand All @@ -173,7 +185,6 @@ public function moveFileTo(
}

return null;

}

/**
Expand Down Expand Up @@ -229,6 +240,8 @@ public function transformFile(Closure $transform): static
$clone->deleteFile();
}

$this->save();

});

return $this;
Expand Down

0 comments on commit de36899

Please sign in to comment.