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'),
    ], validation: ['title' => '

addLayout(string $title, string $name, iterable $fields, ?int $limit = null, iterable $headingAdditionalFields = null, array $validation = [])

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()

use MoonShine\UI\Fields\Email;Layouts::make('Content')
  ->addLayout('Info section', 'info', [
    Email::make('Email')
  ], validation: ['email' => ['

use MoonShine\UI\Fields\Email;Layouts::make('Content')
  ->addLayout('Info section', 'info', [
    Email::make('Email')
  ]),
  ->addLayout('Additionally section', 'additionally', [
    Text::make('Title')
  ])
  ->validation(['info' => ['email' => '

use MoonShine\UI\Fields\Email;Layouts::make('Content')
  ->addLayout('Info section', 'info', [
    Email::make('Email')
  ], validation: ['email' => ['email']], attributes: ['email' => 'E-mail']),
  ->addLayout('Additionally section', 'additionally', [
    Text::make('Title')
  ])
  ->validation(['info' => ['email' => ['