BB
BB
FFilament
Created by BB on 3/2/2025 in #❓┊help
Reorder between Builders
Is it possible to allow reordering between two builders? If block is created in the first one to be able to also be moved in the other builder. Current code:
Repeater::make('content')
->columnSpanFull()
->defaultItems(1)
->schema([
Select::make('columns')
->options([
'grid-cols-1' => "One Column 1/1",
'grid-cols-2-span-2-2' => "Two Columns 2/2",
'grid-cols-2-span-2-4' => 'Two Columns 2/4',
'grid-cols-2-span-4-2' => 'Two Columns 4/2',
])
->default('grid-cols-1')
->live()
->reactive(),

Grid::make()
->columns(2)
->schema(fn (Get $get) => [
Builder::make('column1')
->hiddenLabel()
->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
->addActionLabel(__('Add block'))
->blockNumbers(false)
->collapsible()
->columnSpan(fn (Get $get) => ($get('columns') !== 'grid-cols-1') ? 1 : 12)
->collapsed(fn(string $context): bool => $context !== 'create')
->reorderable()
->cloneable(),

Builder::make('column2')
->hiddenLabel()
->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
->columns((int)$get('column2_width'))
->addActionLabel(__('Add block'))
->blockNumbers(false)
->collapsible()
->collapsed(fn(string $context): bool => $context !== 'create')
->cloneable()
->reorderable()
->visible(fn (Get $get) => $get('columns') !== 'grid-cols-1'),
]),
]),
Repeater::make('content')
->columnSpanFull()
->defaultItems(1)
->schema([
Select::make('columns')
->options([
'grid-cols-1' => "One Column 1/1",
'grid-cols-2-span-2-2' => "Two Columns 2/2",
'grid-cols-2-span-2-4' => 'Two Columns 2/4',
'grid-cols-2-span-4-2' => 'Two Columns 4/2',
])
->default('grid-cols-1')
->live()
->reactive(),

Grid::make()
->columns(2)
->schema(fn (Get $get) => [
Builder::make('column1')
->hiddenLabel()
->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
->addActionLabel(__('Add block'))
->blockNumbers(false)
->collapsible()
->columnSpan(fn (Get $get) => ($get('columns') !== 'grid-cols-1') ? 1 : 12)
->collapsed(fn(string $context): bool => $context !== 'create')
->reorderable()
->cloneable(),

Builder::make('column2')
->hiddenLabel()
->blocks(require app_path('Filament/Blocks/ContentBlocks.php'))
->columns((int)$get('column2_width'))
->addActionLabel(__('Add block'))
->blockNumbers(false)
->collapsible()
->collapsed(fn(string $context): bool => $context !== 'create')
->cloneable()
->reorderable()
->visible(fn (Get $get) => $get('columns') !== 'grid-cols-1'),
]),
]),
4 replies
FFilament
Created by BB on 2/25/2025 in #❓┊help
Multiple panels and resource access (routes)
I have two panels, one for admin and another one for member, they both use the same User model. I've setup the canAccessPanel to allow depending on privilege like this (which works nicely):
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->hasPrivilege(UserPrivilege::DASHBOARD);
}

if ($panel->getId() === 'member') {
return $this->hasPrivilege(UserPrivilege::MEMBER);
}

return false;
}
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->hasPrivilege(UserPrivilege::DASHBOARD);
}

if ($panel->getId() === 'member') {
return $this->hasPrivilege(UserPrivilege::MEMBER);
}

return false;
}
But I noticed when I created resource for the admin, its accessible from the member panel by the route and it returns blank white page instead 404 or 403. Is there something I'm missing to prevent it to give page 404 at or something else, I have the panels providers pretty much unchanged other than using subdomains?
4 replies