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 anartisan 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
Registering the layout
Assign layout classes to the admin model through the$layouts property.
app/Models/Article.php
app/Models/Order.php
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()returningnullskips 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 withsetLayoutsProperty($layouts).
The Vue component
Through theprops 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