Block
The Block
class is used to create blocks within a resource/user, allowing you to organize fields into logical groups.
Available methods:
Method | Description |
---|---|
chunk(string $chunk) | Sets the chunk to which the block will be linked |
title(string $title) | Sets the block title. |
description(string $description) | Sets the block description. |
fields(array $fields) | Defines the list of fields within the block. |
group(string $group) | Adds a block to a group. |
permissions(array $permissions) | Controls where the element is shown based on conditions. |
Permissions
Rule | Description |
---|---|
resource | Comma-separated list of resource IDs. Block is shown only on these resources. |
parent | Parent resource ID(s). Block is shown only for children of these parents. |
template | Template ID(s). Block is shown only on resources with these templates. |
user | User ID(s). Block is shown only for these users. |
user_group | User group ID(s). Block is shown only to users in these groups. |
Example usage:
php
Block::make('Main') // name = Main, title = Main, chunk = main
->description('Basic resource data')
->fields([
Field::make('title')->label('Title'),
Field::make('content')->type('textarea')->label('Content'),
]);
php
Block::make('Hero') // name = Hero, title = Hero
->chunk('hero')
->fields([
Field::make('title')->label('Title'),
Field::make('content')->type('textarea')->label('Content'),
]);
php
Block::make('Hero') // name = Hero, title = Hero
->chunk('hero')
->description('Basic resource data')
->group('Home')
->permissions([
'resource' => '6,7,8',
'parent' => '1',
'template' => '2',
'user' => '1,2',
'user_group' => '1,2'
])
->fields([
Field::make('title')->label('Title'),
Field::make('content')->type('textarea')->label('Content'),
]);