Layout snippets let you place your own components into the existing administration interface.

Creating a layout

A layout is made of two files — a PHP configuration file and the component template assigned to it. Both are created with an artisan command.
The command asks which kind of component you want, Vue or Blade.
With Vue, the component MyCustomLayout.vue is created in resources/views/admin/components/layouts. With Blade, the file MyCustomLayout.blade.php is created in resources/views/admin.

Configuring the layout

The first file is the PHP class holding the settings of the component.
app/Admin/Layouts/MyExampleLayout.php

Position

The $position property decides where the component is placed. A layout without $position is placed on top.
The exact placement of every position is drawn in Slots.

Supplying the component

Components are loaded recursively from resources/views/admin/components. The directory is configurable in the administration configuration.

Registering the layout

Assign layout classes to the admin model through the $layouts property.
app/Models/Article.php
A Vue component needs no PHP class. Use the position as the key, one position can hold more components.
app/Models/Order.php
Create a standalone component with php artisan admin:component OrdersCalendar and answer layout when asked for the component type. A module without a table can replace the whole module view:
app/Models/Dashboard.php
  • build() returning null skips the layout, so a layout can decide at runtime not to render.
  • Unknown positions are ignored.
  • When the component file is not found, the Vue app uses a globally registered component with that name.
  • Layouts can be resolved at runtime with a layouts() method, and extended with setLayoutsProperty($layouts).

The Vue component

Through the props attribute the component receives the record being edited, the newly created record and other information you can work with.
resources/views/admin/components/layouts/MyCustomLayout.vue