Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
StyleCIBot authored and pxpm committed May 21, 2024
1 parent 8da58e7 commit 45eb69c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ protected function handleRepeatableFiles(Model $entry): Model

$processedEntryValues = $this->processRepeatableUploads($entry, $value);

if($this->isFake()) {
if ($this->isFake()) {
$fakeValues = $entry->{$this->getFakeAttribute()} ?? [];

if(is_string($fakeValues)) {
if (is_string($fakeValues)) {
$fakeValues = json_decode($fakeValues, true);
}

Expand All @@ -72,6 +72,7 @@ protected function handleRepeatableFiles(Model $entry): Model
$entry->{$this->getFakeAttribute()} = isset($entry->getCasts()[$this->getFakeAttribute()])
? $fakeValues
: json_encode($fakeValues);

return $entry;
}

Expand Down Expand Up @@ -178,9 +179,9 @@ private function retrieveRepeatableFiles(Model $entry): Model

if ($this->attachedToFakeField) {
$values = $entry->{$this->attachedToFakeField};

$values = is_string($values) ? json_decode($values, true) : $values;

$values[$this->getAttributeName()] = isset($values[$this->getAttributeName()]) ? $this->getValueWithoutPath($values[$this->getAttributeName()]) : null;
$entry->{$this->attachedToFakeField} = isset($entry->getCasts()[$this->attachedToFakeField]) ? $values : json_encode($values);

Expand Down
8 changes: 4 additions & 4 deletions src/app/Library/Uploaders/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ public function uploadFiles(Model $entry, $values = null)
private function retrieveFiles(Model $entry): Model
{
$value = $entry->{$this->getAttributeName()};

if ($this->attachedToFakeField) {
$values = $entry->{$this->attachedToFakeField};

$values = is_string($values) ? json_decode($values, true) : $values;

$values[$this->getAttributeName()] = isset($values[$this->getAttributeName()]) ? $this->getValueWithoutPath($values[$this->getAttributeName()]) : null;
$entry->{$this->attachedToFakeField} = isset($entry->getCasts()[$this->attachedToFakeField]) ? $values : json_encode($values);

Expand Down Expand Up @@ -274,7 +274,7 @@ private function deleteFiles(Model $entry)
$values = is_string($values) ? json_decode($values, true) : $values;
$values = $values[$this->getAttributeName()] ?? null;
}

$values ??= $entry->{$this->getAttributeName()};

if ($values === null) {
Expand Down

0 comments on commit 45eb69c

Please sign in to comment.