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

Save content in a custom db column #38

Closed
flowuerti opened this issue Jul 22, 2019 · 1 comment
Closed

Save content in a custom db column #38

flowuerti opened this issue Jul 22, 2019 · 1 comment

Comments

@flowuerti
Copy link

My reusable and embedded block appears not correctly on the show site.

This is the code for saveing in db:

public function update( Request $request, $id ) {

    $validatedData = $request->validate( [
        'page_title' => 'required|max:255',
        'image'      => 'image|mimes:jpeg,png,jpg,svg|max:2048'
    ] );

    $page               = Page::findOrFail( $id );
    $page->page_title   = $request->page_title;
    $page->page_content = $request->page_content;

    $page->save();

    return redirect()->route( 'pages.edit', $page->id );
}

I do not have not the same database table and column .
What can I do to make it work properly?

My reusable blocks stores correctly and the table (lb_blocks) is present in the database.

@mauricewijnia
Copy link
Member

Your page model should use the Gutenbergable trait:

use VanOns\Laraberg\Models\Gutenbergable;

class Page extends Model {
  use Gutenbergable;
}

Then it has the lb_content property that you can set:

$page = Page::findOrFail( $id );
$page->lb_content = $request->page_content;
$page->save();

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

2 participants