Skip to content

Commit

Permalink
Merge pull request #134 from jan-tricks/main
Browse files Browse the repository at this point in the history
Use Arrayable interface when casting to array
  • Loading branch information
Tarpsvo authored Sep 27, 2024
2 parents e6e3c0d + 9e0b828 commit 3a2e9a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/TranslatableFieldMixin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Outl1ne\NovaTranslatable;

use Exception;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Laravel\Nova\Fields\Markdown;
use Laravel\Nova\Fields\Textarea;
Expand Down Expand Up @@ -44,7 +45,11 @@ public function translatable()
try {
if (!is_array($value)) {
if (is_object($value)) {
$value = (array) $value;
if($value instanceof Arrayable) {
$value = $value->toArray();
} else {
$value = (array) $value;
}
} else {
$testValue = json_decode($value, true);
if (is_array($testValue)) $value = $testValue;
Expand Down

0 comments on commit 3a2e9a8

Please sign in to comment.