### Development Setup Commands
Source: https://github.com/crumbls/layup/blob/main/CONTRIBUTING.md
Commands to clone the repository, install dependencies, run tests, and apply code style fixes.
```bash
git clone https://github.com/Crumbls/layup.git
cd layup
composer install
vendor/bin/pest
vendor/bin/pint
vendor/bin/rector --dry-run
```
--------------------------------
### Get Span Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Illustrates how to get the span configuration after setting it. The output reflects the merged spans, including default values for unspecified breakpoints.
```php
$column = Column::make()->span(['sm' => 12, 'lg' => 6]);
$span = $column->getSpan();
// ['sm' => 12, 'md' => 12, 'lg' => 6, 'xl' => 6]
```
--------------------------------
### Quick Install Layup
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Run this command to perform a complete installation, including publishing configuration, running migrations, creating symlinks, and generating assets.
```bash
php artisan layup:install
```
--------------------------------
### Install Livewire Dependency
Source: https://github.com/crumbls/layup/blob/main/docs/customization/livewire-widgets.md
Install the `livewire/livewire` package using Composer. This is only required if you intend to use `BaseLivewireWidget`.
```bash
composer require livewire/livewire
```
--------------------------------
### Manual Install Layup Steps
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Execute these commands individually if you prefer a manual installation process. This covers configuration publishing, database migrations, storage linking, and asset publishing.
```bash
php artisan vendor:publish --tag=layup-config
```
```bash
php artisan migrate
```
```bash
php artisan storage:link
```
```bash
php artisan filament:assets
```
```bash
php artisan layup:safelist
```
--------------------------------
### Example SEO Configuration
Source: https://github.com/crumbls/layup/blob/main/_autodocs/configuration.md
An example demonstrating how to customize SEO settings, including title suffix, site name, default OG image, home breadcrumb label, and sitemap priority.
```php
'seo' => [
'title_suffix' => ' – Acme Corp',
'site_name' => 'Acme',
'default_og_image' => 'images/og-default.jpg',
'home_breadcrumb_label' => 'Main',
'sitemap_priority' => '0.8',
]
```
--------------------------------
### Install Filament
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Command to install Filament, a prerequisite for Layup. This command installs the Filament package and its panels.
```bash
composer require filament/filament
php artisan filament:install --panels
```
--------------------------------
### Example Content Form Schema
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Widget.md
An example implementation of getContentFormSchema, demonstrating how to define fields for a widget's content, such as title, URL, and style options.
```php
public static function getContentFormSchema(): array
{
return [
TextInput::make('title')
->label('Button Text')
->required(),
TextInput::make('url')
->label('Link URL')
->url(),
Select::make('style')
->options(['primary', 'secondary', 'ghost']),
];
}
```
--------------------------------
### Complete Testimonial Widget Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
A full example of a Filament widget for testimonials, utilizing various Field Packs like image, link, and colorPair for content, author, and styling.
```php
use Crumbls\Layup\View\BaseWidget;
use Crumbls\Layup\Support\FieldPacks;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
class TestimonialWidget extends BaseWidget
{
public static function getType(): string
{
return 'testimonial';
}
public static function getLabel(): string
{
return 'Testimonial';
}
public static function getIcon(): string
{
return 'heroicon-o-chat-bubble-left';
}
public static function getCategory(): string
{
return 'content';
}
public static function getContentFormSchema(): array
{
return [
Textarea::make('content')
->label('Quote')
->required()
->columnSpanFull(),
TextInput::make('author_name')
->label('Author')
->required(),
...FieldPacks::image('author'), // author_src, author_alt
TextInput::make('author_title')
->label('Position'),
...FieldPacks::link('cta'), // cta_url, cta_new_tab
...FieldPacks::colorPair('quote', 'background'), // Colors for styling
];
}
public static function getDefaultData(): array
{
return [
'content' => '',
'author_name' => '',
'author_src' => null,
'author_alt' => '',
'author_title' => '',
'cta_url' => '',
'cta_new_tab' => false,
'quote_color' => '#3b82f6',
'background_color' => '#f9fafb',
];
}
}
```
--------------------------------
### Verify Layup Installation
Source: https://github.com/crumbls/layup/blob/main/docs/field-only-installation.md
Use this command to run a health check on your Layup installation. A warning about the Pages resource being disabled is expected in this installation path.
```bash
php artisan layup:doctor
```
--------------------------------
### Link Pack Form Schema Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
Example of using FieldPacks::link to create URL and new tab toggle fields within a Filament form schema.
```php
public static function getContentFormSchema(): array
{
return [
TextInput::make('button_text')->required(),
...FieldPacks::link('button'), // Creates button_url and button_new_tab
...FieldPacks::link('secondary'), // Creates secondary_url and secondary_new_tab
];
}
```
--------------------------------
### Custom Widget Implementation Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Widget.md
An example of extending the BaseBladeWidget to create a custom widget with specific type, label, icon, form schema, default data, preview, and validation rules.
```php
use Crumbls\Layup\View\BaseBladeWidget;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\RichEditor;
class CustomWidget extends BaseBladeWidget
{
public static function getType(): string
{
return 'custom';
}
public static function getLabel(): string
{
return 'Custom Widget';
}
public static function getIcon(): string
{
return 'heroicon-o-star';
}
public static function getCategory(): string
{
return 'content';
}
public static function getContentFormSchema(): array
{
return [
TextInput::make('title')->required(),
RichEditor::make('description'),
];
}
public static function getDefaultData(): array
{
return [
'title' => '',
'description' => '',
];
}
public static function getPreview(array $data): string
{
return $data['title'] ?? 'Custom Widget';
}
public static function getValidationRules(): array
{
return [
'title' => 'required|string|max:255',
];
}
}
```
--------------------------------
### Use Only Specific Widgets
Source: https://github.com/crumbls/layup/blob/main/docs/customization/extending-widgets.md
Start with no built-in widgets and explicitly register only the ones you intend to use.
```php
LayupPlugin::make()
->withoutConfigWidgets()
->widgets([
\Crumbls\Layup\View\TextWidget::class,
\Crumbls\Layup\View\HeadingWidget::class,
\Crumbls\Layup\View\ImageWidget::class,
\Crumbls\Layup\View\ButtonWidget::class,
\App\Layup\Widgets\BannerWidget::class,
]),
```
--------------------------------
### Get Frontend URL
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Get the frontend URL for the page, based on configuration.
```php
$page->getUrl(): string // Frontend URL based on config prefix
```
--------------------------------
### Register Widget in Config
Source: https://github.com/crumbls/layup/blob/main/docs/customization/livewire-widgets.md
Configuration example for registering a Livewire widget by adding its class to the 'widgets' array in the `config/layup.php` file.
```php
// config/layup.php
'widgets' => [
\App\Layup\Widgets\LiveCounterWidget::class,
// ...
],
```
--------------------------------
### Custom Data Preparation for Rendering (PHP)
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/BaseBladeWidget.md
Example of overriding prepareForRender to resolve storage paths to URLs and merge default values for missing fields.
```php
public static function prepareForRender(array $data): array
{
return [
...$data,
'image_url' => $data['image']
? asset('storage/' . $data['image'])
: null,
];
}
```
--------------------------------
### Install Layup via Composer
Source: https://github.com/crumbls/layup/blob/main/docs/field-only-installation.md
Use this command to add the Layup package to your project dependencies.
```bash
composer require crumbls/layup
```
--------------------------------
### Link Pack Blade Template Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
Example of rendering a link from data generated by FieldPacks::link in a Blade template, including the 'open in new tab' functionality.
```blade
@php
$data = WidgetData::from($data);
@endphp
@if ($data->url('button_url'))
bool('button_new_tab')) target="_blank" rel="noopener noreferrer" @endif
>
{{ $data->string('button_text') }}
@endif
```
--------------------------------
### Color Pair Pack Form Schema Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
Example of using FieldPacks::colorPair to create two color picker fields within a Filament form schema.
```php
public static function getContentFormSchema(): array
{
return [
...FieldPacks::colorPair('text', 'background'), // Creates text_color and background_color
...FieldPacks::colorPair('accent', 'hover'),
];
}
```
--------------------------------
### Color Pair Pack Blade Template Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
Example of rendering content with dynamic text and background colors from data generated by FieldPacks::colorPair in a Blade template.
```blade
@php
$data = WidgetData::from($data);
@endphp
Content here
```
--------------------------------
### Implement Widget Deprecation Logic
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Widget.md
This example shows how to implement both `isDeprecated` and `getDeprecationMessage` to mark a widget as deprecated and provide a migration message.
```php
public static function isDeprecated(): bool
{
return true;
}
public static function getDeprecationMessage(): string
{
return 'Use "Feature Grid" instead — it supports all features of this widget plus more.';
}
```
--------------------------------
### Custom Page Model Configuration
Source: https://github.com/crumbls/layup/blob/main/_autodocs/configuration.md
Example of how to use a custom Eloquent model and database table for pages.
```php
'pages' => [
'model' => App\Models\CustomPage::class,
'table' => 'custom_pages',
]
```
--------------------------------
### Retrieving All Revisions for a Page
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/PageRevision.md
Example of fetching all revisions associated with a specific page, ordered by creation date.
```php
$page = Page::find(1);
// Get all revisions (latest first)
$revisions = $page->revisions()->get();
// Get most recent revision
$latest = $page->revisions()->first();
// Count revisions
$count = $page->revisions()->count();
```
--------------------------------
### CardWidget Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/BaseBladeWidget.md
An example implementation of a CardWidget extending the BaseBladeWidget class. This widget defines its type, label, icon, category, content form schema, default data, preview, and search terms.
```APIDOC
## CardWidget
### Description
This class represents a 'Card' widget, which can be used to display content in a card-like format. It extends the `BaseBladeWidget` and defines its properties and behavior.
### Class Signature
```php
class CardWidget extends BaseBladeWidget
```
### Methods
#### `getType()`
Returns the type of the widget.
- **Returns**: `string` - The widget type, 'card'.
#### `getLabel()`
Returns the user-friendly label for the widget.
- **Returns**: `string` - The widget label, 'Card'.
#### `getIcon()`
Returns the icon associated with the widget.
- **Returns**: `string` - The icon name, 'heroicon-o-rectangle-stack'.
#### `getCategory()`
Returns the category to which the widget belongs.
- **Returns**: `string` - The widget category, 'content'.
#### `getContentFormSchema()`
Defines the schema for the widget's content form, including fields for title, description, image, and call-to-action.
- **Returns**: `array` - An array representing the form schema.
#### `getDefaultData()`
Provides the default data values for the widget's fields.
- **Returns**: `array` - An associative array of default data.
#### `getPreview(array $data)`
Generates a preview string for the widget based on the provided data.
- **Parameters**:
- **data** (array) - The data to use for the preview.
- **Returns**: `string` - The preview string.
#### `getSearchTerms()`
Returns an array of search terms associated with the widget.
- **Returns**: `array` - An array of search terms.
```
--------------------------------
### Set Default Breakpoint
Source: https://github.com/crumbls/layup/blob/main/_autodocs/configuration.md
Specify the starting breakpoint when the builder is opened. Defaults to 'lg' (desktop view).
```php
'default_breakpoint' => 'lg',
```
--------------------------------
### Column Data Structure Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Illustrates the expected data structure for a column when stored in page content, including responsive span settings and widget configurations.
```json
{
"span": {
"sm": 12,
"md": 6,
"lg": 4,
"xl": 3
},
"settings": {
"align_self": "auto",
"overflow": "visible",
"bg_color": "#ffffff",
"padding": ["top" => "16", ...],
"margin": [...],
"border": [...],
"responsive_visibility": [...]
},
"widgets": [
{ "type" => "text", "data" => {...} },
{ "type" => "button", "data" => {...} }
]
}
```
--------------------------------
### Get Widget Preview Text
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetRegistry.md
Generate a short preview string for a widget based on its type and provided data. This is typically shown in a builder interface.
```php
public function getPreview(string $type, array $data): string
```
```php
$preview = $registry->getPreview('text', ['content' => 'Hello World']);
// Returns shortened preview of the content
```
--------------------------------
### Implement Custom Page Controller
Source: https://github.com/crumbls/layup/blob/main/docs/customization/frontend-rendering.md
Extend AbstractController to define custom logic for retrieving and displaying pages. This example shows how to fetch a published page by its slug.
```php
where('slug', $request->route('slug'))
->firstOrFail();
}
}
```
--------------------------------
### Provide Default Widget Data (PHP)
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/BaseBladeWidget.md
Example of overriding getDefaultData to return a structured array of default values for a widget.
```php
public static function getDefaultData(): array
{
return [
'title' => '',
'description' => '',
'show_image' => true,
'item_count' => 5,
];
}
```
--------------------------------
### Widget Test Example: Default Data
Source: https://github.com/crumbls/layup/blob/main/CONTRIBUTING.md
Tests if a widget renders with default data and produces non-empty HTML output.
```php
it('renders with default data', function () {
$widget = new MyWidget(['data' => MyWidget::getDefaultData()]);
$html = $widget->render()->render();
expect($html)->toBeString()->not->toBeEmpty();
});
```
--------------------------------
### Run Layup Database Migrations
Source: https://github.com/crumbls/layup/blob/main/docs/field-only-installation.md
Execute this command to create the necessary database tables for Layup.
```bash
php artisan migrate
```
--------------------------------
### Example LayupBuilder Row Templates Return Value
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/LayupBuilder.md
Shows the structure of the array returned by `getRowTemplatesProperty()`, demonstrating various column span configurations for rows.
```php
[
[12], // Full width
[6, 6], // Two equal columns
[4, 4, 4], // Three equal columns
[3, 3, 3, 3], // Four equal columns
[8, 4], // 2/3 + 1/3
[4, 8], // 1/3 + 2/3
]
```
--------------------------------
### Get Used CSS Classes
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Get a list of all CSS classes used within the page's content.
```php
$page->getUsedClasses(): array // CSS classes in content
```
--------------------------------
### Dark Mode CSS Override Example
Source: https://github.com/crumbls/layup/blob/main/docs/customization/theme-system.md
Example of CSS showing a manual override for a primary color in dark mode.
```css
:root { --layup-primary: #e11d48; }
.dark { --layup-primary: #fb7185; } /* manual override */
```
--------------------------------
### Creating and Rendering a Row with Columns in PHP
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Row.md
This example demonstrates how to create a Row instance with specific data attributes and associate Column children with it. The render method outputs the HTML for the row.
```php
// In a service that processes page content
use Crumbls\Layup\View\Row;
use Crumbls\Layup\View\Column;
$columns = [
Column::make(['span' => 6], [/* widgets */]),
Column::make(['span' => 6], [/* widgets */]),
];
$row = Row::make(
data: [
'direction' => 'row',
'justify' => 'between',
'align' => 'center',
'full_width' => false,
'bg_color' => '#f9fafb',
'padding' => ['top' => '32', 'bottom' => '32', 'left' => '0', 'right' => '0'],
],
children: $columns
);
echo $row->render(); // Renders the HTML row
```
--------------------------------
### Layup Field Example
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Example of how to use the LayupBuilder field in a Filament form. This field is used to create structured content within your application.
```php
use Crumbls\Layup\Forms\Components\LayupBuilder;
LayupBuilder::make('content')->columnSpanFull()
```
--------------------------------
### Create a Livewire-rendered widget
Source: https://github.com/crumbls/layup/blob/main/docs/customization/_index.md
Extend the `BaseLivewireWidget` class to make a widget render through Livewire.
```php
BaseLivewireWidget
```
--------------------------------
### Create Sidebar Layout with Custom Data
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Illustrates an advanced layout example creating a main content area (8 columns) and a sidebar (4 columns) for desktop viewports. It also shows how to pass custom data attributes, such as background color and padding, to a column.
```php
// Main content (8 columns) + Sidebar (4 columns)
$columns = [
Column::make([], [$mainContent])
->span(['lg' => 8, 'md' => 12]),
Column::make(
data: [
'bg_color' => '#f3f4f6',
'padding' => ['top' => '24', 'bottom' => '24', 'left' => '16', 'right' => '16'],
],
children: [$sidebar]
)->span(['lg' => 4, 'md' => 12]),
];
```
--------------------------------
### WidgetData Construction
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetData.md
Demonstrates how to create new instances of WidgetData using its constructor or a static factory method.
```APIDOC
## WidgetData Construction
### Description
Creates a new WidgetData instance.
### Method
`__construct(array $data)`
### Parameters
#### Path Parameters
- **data** (array) - Required - The raw widget data
### Method
`from(array $data): static`
### Description
Static factory method for creating instances.
### Parameters
#### Path Parameters
- **data** (array) - Required - The raw widget data
### Returns
`static` - New WidgetData instance
### Example
```php
$data = WidgetData::from(['title' => 'Hello', 'count' => 5]);
```
```
--------------------------------
### Create Storage Symlink
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Run this command to make uploaded images accessible via the web. This creates a symbolic link from 'public/storage' to 'storage/app/public'.
```bash
php artisan storage:link
```
--------------------------------
### Widget Configuration
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetRegistry.md
Configure widget registration and discovery settings in the `config/layup.php` file. Auto-discovery scans specified namespaces for widget implementations.
```php
'widgets' => [
\Crumbls\Layup\View\TextWidget::class,
\Crumbls\Layup\View\ButtonWidget::class,
// ... 96 built-in widgets
],
'widget_discovery' => [
'namespace' => 'App\\Layup\\Widgets',
'directory' => null, // defaults to app_path('Layup/Widgets')
],
```
--------------------------------
### Column Span Example
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Demonstrates chaining the span method to set a default full width and then overriding it for larger desktop screens. The span method returns the static instance for chaining.
```php
Column::make()
->span(12) // Full width by default
->span(['lg' => 6]); // 50% on desktop, stays 12 on smaller screens
```
--------------------------------
### Get Revisions
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Retrieve all revisions associated with a page.
```php
$page->revisions(): HasMany
```
--------------------------------
### Configure LayupPlugin for Multiple Panels
Source: https://github.com/crumbls/layup/blob/main/docs/customization/filament-plugin-api.md
Demonstrates how to configure independent `LayupPlugin` instances for different Filament panels, allowing for unique widget sets and theme colors per panel.
```php
// AdminPanelProvider.php
LayupPlugin::make()
->colors(['primary' => '#1e40af'])
->widgets([\App\Layup\Widgets\AdminOnly::class])
// MarketingPanelProvider.php
LayupPlugin::make()
->colors(['primary' => '#10b981'])
->withoutWidgets([\Crumbls\Layup\View\CodeWidget::class])
```
--------------------------------
### Get Meta Keywords
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the meta keywords for the page.
```APIDOC
## `getMetaKeywords(): ?string`
### Description
Returns the meta keywords.
### Method Signature
```php
public function getMetaKeywords(): ?string
```
### Returns
`string|null` - Value from `meta['keywords']` or null
```
--------------------------------
### Get Meta Description
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the meta description for the page.
```APIDOC
## `getMetaDescription(): ?string`
### Description
Returns the meta description.
### Method Signature
```php
public function getMetaDescription(): ?string
```
### Returns
`string|null` - Value from `meta['description']` or null
```
--------------------------------
### Create WidgetData Instance using Static Factory
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetData.md
Use the static `from` method as an alternative way to create a new WidgetData instance. It accepts an array of data.
```php
public static function from(array $data): static
```
```php
$data = WidgetData::from(['title' => 'Hello', 'count' => 5]);
```
--------------------------------
### Get Meta Keywords
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the meta keywords for the page.
```php
public function getMetaKeywords(): ?string
```
--------------------------------
### Get Meta Description
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the meta description for the page.
```php
public function getMetaDescription(): ?string
```
--------------------------------
### Publish Filament Assets and Storage Symlink
Source: https://github.com/crumbls/layup/blob/main/docs/field-only-installation.md
These commands are necessary for registering Layup's CSS and making uploaded media accessible.
```bash
php artisan filament:assets
php artisan storage:link
```
--------------------------------
### Example Usage of Hover Colors Field Pack
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/FieldPacks.md
Demonstrates how to integrate the hoverColors field pack into a Filament form schema to create four color picker fields with a specified prefix.
```php
public static function getContentFormSchema(): array
{
return [
TextInput::make('label')->required(),
...FieldPacks::hoverColors('button'), // Creates 4 color fields with "button_" prefix
];
}
```
--------------------------------
### Get Meta Title
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Retrieve the meta title for SEO purposes.
```php
$page->getMetaTitle(): string
```
--------------------------------
### Get Children Pages
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Access the direct children of a given page.
```php
$page->children(): HasMany // Direct children
```
--------------------------------
### Get Sitemap Entries
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Generate data for sitemap entries from all published pages.
```php
Page::sitemapEntries(): array // All published pages as sitemap data
```
--------------------------------
### Get Structured Data
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Retrieve structured data (JSON-LD schemas) for SEO.
```php
$page->getStructuredData(): array // JSON-LD schemas
```
--------------------------------
### Configure Upload Disk
Source: https://github.com/crumbls/layup/blob/main/docs/widgets/media.md
Configure the default upload disk for media widgets. Ensure the disk is publicly accessible.
```php
[
'disk' => 'public',
],
// ... other configuration options
];
```
--------------------------------
### Define Breakpoint Configurations
Source: https://github.com/crumbls/layup/blob/main/_autodocs/types.md
Configure responsive breakpoints for your application. Each breakpoint defines a label, minimum width, and an optional icon.
```php
[
'sm' => [
'label' => 'sm',
'width' => 640,
'icon' => 'heroicon-o-device-phone-mobile',
],
'md' => [
'label' => 'md',
'width' => 768,
'icon' => 'heroicon-o-device-tablet',
],
'lg' => [
'label' => 'lg',
'width' => 1024,
'icon' => 'heroicon-o-computer-desktop',
],
'xl' => [
'label' => 'xl',
'width' => 1280,
'icon' => 'heroicon-o-tv',
],
]
```
--------------------------------
### Get Parent Page Revision
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Access the parent page associated with a specific revision.
```php
$revision->page(): BelongsTo // Parent page
```
--------------------------------
### Configure File Uploads
Source: https://github.com/crumbls/layup/blob/main/_autodocs/configuration.md
Configure file upload settings, including the filesystem disk and the maximum file size in KB. The specified disk must exist in 'config/filesystems.php'.
```php
'uploads' => [
'disk' => 'public',
'max_size' => 10240, // 10 MB in KB
],
```
--------------------------------
### Get Deprecation Message
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/BaseBladeWidget.md
Retrieves the message explaining why a widget is deprecated. Defaults to an empty string.
```php
public static function getDeprecationMessage(): string
{
return 'Use "Advanced Card" instead.';
}
```
--------------------------------
### Get Meta Tags
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns all meta tags as a flat array suitable for template use.
```APIDOC
## `getMetaTags(): array`
### Description
Returns all meta tags as a flat array suitable for template use.
### Method Signature
```php
public function getMetaTags(): array
```
### Returns
`array` - Filtered array of:
- `title` - Meta title
- `description` - Meta description
- `keywords` - Meta keywords
```
--------------------------------
### Serve Pages at Site Root
Source: https://github.com/crumbls/layup/blob/main/docs/customization/frontend-rendering.md
Set the 'prefix' to an empty string to serve pages directly at the site root. Layup automatically excludes framework paths.
```php
'frontend' => [
'prefix' => '',
]
```
--------------------------------
### Get Meta Tags
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns all meta tags as a flat array suitable for template use.
```php
public function getMetaTags(): array
```
--------------------------------
### Accessing Parent Page from Revision
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/PageRevision.md
Example of how to retrieve the parent Page model from a PageRevision instance.
```php
$revision = PageRevision::find(1);
$page = $revision->page; // Parent Page model
```
--------------------------------
### Publish Layup Assets
Source: https://github.com/crumbls/layup/blob/main/docs/installation.md
Use these commands to publish Layup's configuration, views, routes, scripts, templates, translations, and stubs.
```bash
php artisan vendor:publish --tag=layup-config
```
```bash
php artisan vendor:publish --tag=layup-views
```
```bash
php artisan vendor:publish --tag=layup-routes
```
```bash
php artisan vendor:publish --tag=layup-scripts
```
```bash
php artisan vendor:publish --tag=layup-templates
```
```bash
php artisan vendor:publish --tag=layup-translations
```
```bash
php artisan vendor:publish --tag=layup-stubs
```
--------------------------------
### Construct WidgetData Instance
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetData.md
Creates a new WidgetData instance with the provided raw data. This is the primary way to initialize the object.
```php
public function __construct(protected array $data)
```
--------------------------------
### Get Content Tree
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Retrieve the page's content as a tree of Row, Column, and Widget objects.
```php
$page->getContentTree(): array // Get Row/Column/Widget object tree
```
--------------------------------
### Assert Widget Renders
Source: https://github.com/crumbls/layup/blob/main/docs/customization/livewire-widgets.md
Use these assertions to verify that a widget renders non-empty output, whether it returns a View, Htmlable, or string. This works for both base and Livewire widgets.
```php
$this->assertWidgetRenders('live-counter');
$this->assertWidgetRendersWithDefaults(LiveCounterWidget::class);
```
--------------------------------
### Get Parent Page
Source: https://github.com/crumbls/layup/blob/main/docs/api-reference/models.md
Access the parent page of a given page. Returns null for top-level pages.
```php
$page->parent(): BelongsTo // Parent page (or null for top-level)
```
--------------------------------
### LayupPlugin::make()
Source: https://github.com/crumbls/layup/blob/main/docs/customization/filament-plugin-api.md
The main entry point for customizing Layup at the Filament panel level. All methods are fluent and return the plugin instance for chaining.
```APIDOC
## LayupPlugin::make()
### Description
Initializes a new instance of the LayupPlugin. This is the primary method to start configuring Layup within a Filament panel.
### Method
static make()
### Parameters
None
### Request Example
```php
LayupPlugin::make()
```
### Response
Returns a new instance of `LayupPlugin`.
```
--------------------------------
### Get Meta Title
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the page's meta title, optionally appending a site-wide suffix.
```APIDOC
## `getMetaTitle(): string`
### Description
Returns the page's meta title with optional site-wide suffix appended.
### Method Signature
```php
public function getMetaTitle(): string
```
### Returns
`string` - Meta title from `meta['title']` with optional `config('layup.seo.title_suffix')` appended.
### Example
```php
// Assuming meta.title = "About Us" and title_suffix = " – Acme Corp"
$page->getMetaTitle(); // "About Us – Acme Corp"
```
```
--------------------------------
### Get Meta Title
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Page.md
Returns the page's meta title, optionally appending a site-wide suffix.
```php
public function getMetaTitle(): string
```
```php
// Assuming meta.title = "About Us" and title_suffix = " – Acme Corp"
$page->getMetaTitle(); // "About Us – Acme Corp"
```
--------------------------------
### BaseView::buildInlineStyles Example
Source: https://github.com/crumbls/layup/blob/main/AGENTS.md
Compiles Design tab fields into a CSS string for inline styles. Pass the entire data array to handle various style properties like color, alignment, and background.
```php
// Output: "color: #333; text-align: center; font-size: 1.25rem; background-color: #f0f0f0;"
```
--------------------------------
### Getting Column Span Configuration
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Retrieves the current span configuration for the column across all defined breakpoints.
```APIDOC
## `getSpan(): array`
### Description
Returns the column's span configuration.
### Returns
`array` - Breakpoint-keyed span values
### Example
```php
$column = Column::make()->span(['sm' => 12, 'lg' => 6]);
$span = $column->getSpan();
// ['sm' => 12, 'md' => 12, 'lg' => 6, 'xl' => 6]
```
```
--------------------------------
### Get LayupBuilder Translations
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/LayupBuilder.md
Bundles all UI text strings used within the LayupBuilder interface for localization.
```php
public function getTranslationsProperty(): array
```
--------------------------------
### Get LayupBuilder Widget Registry
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/LayupBuilder.md
Access the widget registry, which is serialized for use by the frontend JavaScript (Alpine.js).
```php
public function getWidgetRegistryProperty(): array
```
--------------------------------
### Configure Frontend Rendering
Source: https://github.com/crumbls/layup/blob/main/docs/configuration.md
Customize frontend route registration, URL prefix, middleware, domain, layout, view, container width, script inclusion, and excluded paths.
```php
'frontend' => [
'enabled' => true,
'prefix' => 'pages',
'middleware' => ['web'],
'domain' => null,
'layout' => 'app',
'view' => 'layup::frontend.page',
'max_width' => 'container',
'include_scripts' => true,
'excluded_paths' => [],
],
```
--------------------------------
### Frontend Rendering Configuration
Source: https://github.com/crumbls/layup/blob/main/_autodocs/configuration.md
Configures frontend page rendering, including route prefix, middleware, and layout.
```php
'frontend' => [
'enabled' => true,
'prefix' => 'pages',
'middleware' => ['web'],
'domain' => null,
'layout' => 'app',
'view' => 'layup::frontend.page',
'max_width' => 'container',
'include_scripts' => true,
'excluded_paths' => [],
]
```
--------------------------------
### Register WidgetRegistry as a Singleton
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetRegistry.md
Integrate the WidgetRegistry into your application by registering it as a singleton within your service provider. This ensures a single instance is used throughout the application.
```php
$this->app->singleton(WidgetRegistry::class, fn (): WidgetRegistry => new WidgetRegistry);
```
--------------------------------
### Generate New Widget with Artisan
Source: https://github.com/crumbls/layup/blob/main/docs/customization/custom-widgets.md
Use this command to create a new widget class and its corresponding Blade view. Add `--with-test` to also generate a Pest test file.
```bash
php artisan layup:make-widget BannerWidget
```
```bash
php artisan layup:make-widget BannerWidget --with-test
```
--------------------------------
### Checking and Retrieving Widgets
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/WidgetRegistry.md
Check if a widget is registered using its key, retrieve its class name, and get its default data.
```php
$registry = app(WidgetRegistry::class);
if ($registry->has('custom_widget')) {
$class = $registry->get('custom_widget');
$data = $registry->getDefaultData('custom_widget');
}
```
--------------------------------
### Get Layup Content Column Name
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/HasLayupContent.md
Retrieve the name of the column used for storing Layup content. Defaults to 'content'.
```php
protected function getLayupContentColumn(): string
{
return 'builder_content'; // Use 'builder_content' column instead
}
```
--------------------------------
### Register Widget Programmatically
Source: https://github.com/crumbls/layup/blob/main/docs/customization/livewire-widgets.md
Programmatic registration of a Livewire widget using the `WidgetRegistry` in a service provider.
```php
app(\Crumbls\Layup\Support\WidgetRegistry::class)
->register(\App\Layup\Widgets\LiveCounterWidget::class);
```
--------------------------------
### Get LayupBuilder Breakpoints
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/LayupBuilder.md
Retrieve all configured responsive breakpoints for the LayupBuilder. This is useful for understanding the available screen size configurations.
```php
public function getBreakpointsProperty(): array
```
--------------------------------
### Column Constructor
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Initializes a new Column instance with optional data for settings and child widgets.
```APIDOC
## `__construct(array $data = [], array $children = [])`
### Description
Creates a new Column instance.
### Parameters
#### Path Parameters
- **data** (array) - Required - Column settings including span configuration
- **children** (array) - Required - Widget objects contained in this column
```
--------------------------------
### Create Responsive 3-Column Layout
Source: https://github.com/crumbls/layup/blob/main/_autodocs/api-reference/Column.md
Demonstrates how to create a responsive 3-column layout using the Column component. Each column is configured to span different widths based on screen size: full width on mobile, 50% on tablet, and 33% on desktop. This snippet requires the `Column`, `Widget`, and `Row` classes.
```php
use Crumbls\Layup\View\Column;
use Crumbls\Layup\View\Widget;
// Create a responsive 3-column layout:
// - Mobile: 1 column (full width)
// - Tablet: 2 columns (50% each)
// - Desktop: 3 columns (33% each)
$columns = [
Column::make([], [$widget1])
->span(['sm' => 12, 'md' => 6, 'lg' => 4]),
Column::make([], [$widget2])
->span(['sm' => 12, 'md' => 6, 'lg' => 4]),
Column::make([], [$widget3])
->span(['sm' => 12, 'md' => 6, 'lg' => 4]),
];
$row = Row::make(['justify' => 'between'], $columns);
echo $row->render();
```