Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse incoming Flexible content, data should be an array Error #527

Open
bluestar0505 opened this issue Nov 12, 2024 · 0 comments

Comments

@bluestar0505
Copy link

I want to save all images to one json column(custom_images),
But the following error is occurring.

Unable to parse incoming Flexible content, data should be an array. at /var/www/vhosts/4kvin.com/httpdocs/vendor/whitecube/nova-flexible-content/src/Flexible.php:409)

Car.php

public function image(): HasOne
{
 return $this->hasOne(Image::class)->latestOfMany();
}

Image.php

protected $casts = [
 'custom_images' => 'array',
 ];

public function car(): BelongsTo
{
 return $this->belongsTo(Car::class);
 }

CarResource.php

 public function fields(NovaRequest $request)
 {

 return [
            ID::make()->sortable(),
            HasOne::make('Images', 'image', ImageResource::class),
  ];
 }

ImageResource.php

public function fields(NovaRequest $request)
  {
  return [
              Flexible::make('Images', 'custom_images')
                ->addLayout('Image', 'image', [
                    ImageField::make('Image')
                        ->disk('custom_images') 
                        ->rules( 'image', 'max:2048')
                        ->thumbnail(function ($value, $disk) {
                            return $value
                                ? Storage::disk($disk)->url($value)
                                : null;
                        })
                ])->button('Add Image'),

        ];
}

Laravel 10.10
Nova 4.35
nova-flexible-content 1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant