Skip to content

Commit

Permalink
Merge pull request #10 from toneflix/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
3m1n3nc3 authored Jul 29, 2024
2 parents b4cc423 + c62b3c0 commit b115174
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.updated
.idea
.phpunit.cache
.DS_Store
build
composer.lock
coverage
Expand Down
7 changes: 3 additions & 4 deletions src/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ public function dynamicFile(string $file)
*
* @param ?string $file_name
* @param ?string $old
* @param ?string $index
*/
public function save(string $type, ?string $file_name = null, ?string $old = null, ?string $index = null): ?string
public function save(string $type, ?string $file_name = null, ?string $old = null, string|int|null $index = null): ?string
{
// Get the file path
$getPath = Arr::get($this->namespaces, $type.'.path');
Expand All @@ -207,7 +206,7 @@ public function save(string $type, ?string $file_name = null, ?string $old = nul
$fileKey = $fn->replace('.*.', ".$index.")->toString();
$fileList = $fn->contains('.*.') ? Arr::dot($request->allFiles()) : null;

if ($request->hasFile($file_name) && (! $index || isset($fileList[$fileKey]))) {
if ($request->hasFile($file_name) && (! is_null($index) || isset($fileList[$fileKey]))) {
if ($old && $this->disk->exists($old_path) && $old !== 'default.png') {
$this->disk->delete($old_path);
}
Expand All @@ -216,7 +215,7 @@ public function save(string $type, ?string $file_name = null, ?string $old = nul
// This is useful when you have multiple files with the same name
if (isset($fileList[$fileKey])) {
$requestFile = $fileList[$fileKey];
} elseif ($index !== null && isset($request->file($file_name)[$index])) {
} elseif (! is_null($index) && isset($request->file($file_name)[$index])) {
$requestFile = $request->file($file_name)[$index];
} else {
$requestFile = $request->file($file_name);
Expand Down

0 comments on commit b115174

Please sign in to comment.