1. Go to this page and download the library: Download webx-ui/module-blocks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webx-ui / module-blocks example snippets
Schema::table('pages', function (Blueprint $table) {
$table->blocks(); // `blocks` json — the tree the site prints
$table->draft(); // `draft` json and `published_at`, from webx-ui/module-admin
});
class Page extends Model
{
use HasBlocks, HasDraft, HasVersions;
}
$page->blocks; // [{ key, type, values }, …]
$page->renderBlocks(); // HtmlString
$page->blockTypes(); // ['hero', 'section', 'text'] — nested ones
BlockTypes::all(); // enabled types with a published version, in sort order — the picker
BlockTypes::find('hero'); // the published version, disabled or not — what the site renders
BlockTypes::draft('hero'); // the draft, or the published one when there is none — the preview