Skip to content

Commit

Permalink
Merge pull request #288 from levchenko-ivan/fix_delete_file
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to authored May 21, 2023
2 parents 8e4a192 + 264d27e commit c1975ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Traits/Fields/FileDeletable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MoonShine\Traits\Fields;

use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;

Expand Down Expand Up @@ -37,7 +38,7 @@ public function enableDeleteDir(): static

public function checkAndDelete(
iterable|string|null $storedValues,
array $inputValues
array|string $inputValues
): void {
if($storedValues instanceof Collection) {
$storedValues = $storedValues->toArray();
Expand All @@ -47,6 +48,8 @@ public function checkAndDelete(
return;
}

$inputValues = Arr::wrap($inputValues);

if ($this->isMultiple()) {
foreach ($storedValues as $storedValue) {
if(! in_array($storedValue, $inputValues)) {
Expand Down

0 comments on commit c1975ea

Please sign in to comment.