Skip to content

Commit

Permalink
Merge pull request #79 from BBS-Lab/develop
Browse files Browse the repository at this point in the history
fix(upload): fix an issue where a file could not be uploaded in a subdirectory when a file with same name exists in the root directory
  • Loading branch information
mikaelpopowicz authored Sep 10, 2022
2 parents 5144db6 + e9c1f6a commit c18f48c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Rules/FileMissingInFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace BBSLab\NovaFileManager\Rules;

use BBSLab\NovaFileManager\Http\Requests\BaseRequest;
use BBSLab\NovaFileManager\Http\Requests\UploadFileRequest;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Str;

class FileMissingInFilesystem implements Rule
{
public ?string $path = null;

public function __construct(public BaseRequest $request)
public function __construct(public UploadFileRequest $request)
{
}

Expand All @@ -22,16 +23,16 @@ public function __construct(public BaseRequest $request)
*/
public function passes($attribute, $value): bool
{
$this->path = $value->getClientOriginalName();
$this->path = Str::finish($this->request->path, '/').$value->getClientOriginalName();

return $this->request
->manager()
->filesystem()
->missing($value->getClientOriginalName());
->missing($this->path);
}

public function message(): string
{
return __('nova-file-manager::validation.path.missing', ['path' => $this->path]);
return __('nova-file-manager::validation.path.exists', ['path' => $this->path]);
}
}

0 comments on commit c18f48c

Please sign in to comment.