Skip to content

Get data from block_editor in SEO trait #1075

Answered by pboivin
PL-Antony asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @EPInformatyka,

If I understand correctly, you want to get some data that exists in a block and use it from a controller, not from a blade view. This will depend on the structure of your project, but here's a quick example that should get you going.

Let's say you have an instance of a Project model and want to fetch the title property from the first block:

if ($block = $project->blocks()->first()) {
    $title = $block->content['title'] ?? $defaultTitle;
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PL-Antony
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