Skip to content

Updating an existing statamic entry with new data #4910

Answered by jasonvarga
RohanKambleDev asked this question in Q&A
Discussion options

You must be logged in to vote

The field you need to modify is the top level blocks.

You'll need to get the value of that, modify it, and then re-set it.

$blocks = $entry->get('blocks');

// I don't know how you're picking which block to update.
// If it's just the first "video_block" block, then this will do it.
$index = collect($blocks)->search(function ($block) {
    return $block['type'] === 'video_block';
});

$blocks[$index]['add_videos'][] = ['title' => 'Entry from Laravel Test Rohan'];

$entry->set('blocks', $blocks);
$entry->save();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RohanKambleDev
Comment options

Answer selected by RohanKambleDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants