PHP code example of secondnetwork / voyager-page-blocks

1. Go to this page and download the library: Download secondnetwork/voyager-page-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/ */

    

secondnetwork / voyager-page-blocks example snippets


$blocks['company_overview'] = [
    'name' => 'Company Overview',
    'template' => 'voyager-page-blocks::blocks.company_overview',
    'fields' => [
        'content' => [
            'field' => 'content',
            'display_name' => 'Company Overview Content',
            'type' => 'rich_text_box',
            '

class PagesController extends Controller
{
    protected $theme = '';

    public function index()
    {
        $page = Page::where('slug', 'startseite');
        $page = $page->firstOrFail();
        $block = DB::table('page_blocks')
            ->where('page_id', '=', $page->id)
            ->where('is_hidden', '=', '0')
            ->orderBy('order', 'asc')
            ->get();
        return view('theme::pages.default', compact('page', 'block', 'posts'));
    }

@if (!empty($block))
@foreach($block as $blockTemp)
    @if (!empty($blockTemp->type))
        @php
        $template = $blockTemp->path;
        $blockData = json_decode($blockTemp->data);
        @endphp
        
        @             </div>
            </div>
        </div>
    @endif
@endforeach
@else
<h1>
  {{ $page->title }}
</h1>
<div class="page-content">
  {!! $page->body !!}
</div>
@endif
bash
php artisan voyager-page-blocks:install
bash
php artisan voyager-page-blocks:seed