PHP code example of banulakwin / laravel-page-builder
1. Go to this page and download the library: Download banulakwin/laravel-page-builder 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/ */
banulakwin / laravel-page-builder example snippets
use Banulakwin\PageBuilder\Support\PageRegistry;
$definitions = PageRegistry::publicFieldMetadataBySection('home');
$commonDefinitions = PageRegistry::publicFieldMetadataBySection('__common');
use Banulakwin\PageBuilder\Services\PageService;
use Inertia\Inertia;
public function index(PageService $pageService)
{
return Inertia::render('Home', [
'page' => $pageService->getPage('home'),
]);
}
use Banulakwin\PageBuilder\Services\PageService;
use Inertia\Inertia;
public function __construct(
protected PageService $pageService,
) {}
public function index()
{
return Inertia::render('Home', [
'page' => $this->pageService->getPage('home'),
]);
}
use Banulakwin\PageBuilder\Facades\Page;
use Inertia\Inertia;
return Inertia::render('Home', [
'page' => Page::getPage('home'),
]);
use Banulakwin\PageBuilder\Support\FieldResolver;
use Banulakwin\PageBuilder\Support\PageRegistry;
public function update(Request $request, FieldResolver $fieldResolver)
{
$pages = PageRegistry::all();
$fields = (array) ($pages['home']['sections']['hero']['fields'] ?? []);
$fieldResolver->handleSave($request, 'home', 'hero', $fields);
return redirect()->back();
}
use Banulakwin\PageBuilder\Services\PageService;
use Inertia\Inertia;
public function index(PageService $pageService)
{
return Inertia::render('Home', [
'page' => $pageService->getPage('home'),
]);
}