PHP code example of moonshine / layouts-field

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

    

moonshine / layouts-field example snippets


use MoonShine\Layouts\Fields\Layouts;

Layouts::make('Content')
    ->addLayout('Contact information', 'contacts', [
        Text::make('Name'),
        Email::make('Email'),
    ])
     ->addLayout('Banner section', 'banner', [
        Text::make('Title'),
        Image::make('Banner image', 'thumbnail'),
    ]),

addLayout(string $title, string $name, iterable $fields, ?int $limit = null)

use MoonShine\Layouts\Casts\LayoutsCast;

class Article extends Model
{
    protected function casts(): array
    {
        return [
            'content' => LayoutsCast::class,
        ];
    }
}

Layouts::make('Content', 'content')
    ->addButton(ActionButton::make('New layout')->icon('plus')->primary())

Layouts::make('Content')
    ->addButton(ActionButton::make('New layout')->icon('plus')->primary())

Layouts::make('Content')
  ->addLayout('Info section', 'info', [
    ...
  ])
  ...
  ->addLayout('Slider section', 'slider', [
    ...
  ])
  ->searchable()