Skip to content

Feat/global blocks#16

Merged
GigaGiorgadze merged 9 commits intomainfrom
feat/global-blocks
Sep 11, 2025
Merged

Feat/global blocks#16
GigaGiorgadze merged 9 commits intomainfrom
feat/global-blocks

Conversation

@mishatch
Copy link
Contributor

@mishatch mishatch commented Sep 9, 2025

No description provided.

Comment on lines +209 to +223
protected function publishGlobalBlockMigration(): void
{
$timestamp = now()->format('Y_m_d_His');
$migrationName = 'create_global_block_configs_table';
$migrationFile = database_path("migrations/{$timestamp}_{$migrationName}.php");

$this->createFileFromStub(
'create_global_block_configs_table.php',
$migrationFile,
[]
);

$this->info("Created migration: {$migrationFile}");
$this->warn("Don't forget to run 'php artisan migrate' to create the global_block_configs table.");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to include this in a command, this can just be republished like other mgirations

Comment on lines +165 to +207
protected function createGlobalBlocksResource(): void
{
$resourceNamespace = $this->getClassNameSpaces('Resources');
$resourceClass = 'GlobalBlocksResource';
$resourceFullClass = $resourceNamespace . '\\' . $resourceClass;

$this->createFileFromStub(
'global-blocks-resource',
$this->appClassToPath($resourceFullClass),
[
'{{ class }}' => $resourceClass,
'{{ namespace }}' => $resourceNamespace,
'{{ resourceNamespace }}' => $resourceNamespace,
]
);

$pagesNamespace = $resourceNamespace . '\\' . $resourceClass . '\\Pages';

$this->createFileFromStub(
'global-blocks-list-page',
$this->appClassToPath($pagesNamespace . '\\ListGlobalBlocks'),
[
'{{ class }}' => 'ListGlobalBlocks',
'{{ namespace }}' => $pagesNamespace,
'{{ resourceClass }}' => $resourceClass,
'{{ resourceNamespace }}' => $resourceNamespace,
]
);

$this->createFileFromStub(
'global-blocks-edit-page',
$this->appClassToPath($pagesNamespace . '\\EditGlobalBlock'),
[
'{{ class }}' => 'EditGlobalBlock',
'{{ namespace }}' => $pagesNamespace,
'{{ resourceClass }}' => $resourceClass,
'{{ resourceNamespace }}' => $resourceNamespace,
]
);

$this->info("Created Global Blocks resource at: {$resourceFullClass}");
$this->info('The resource has been automatically registered and will appear in your Filament panel navigation.');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding this block resource, its better if this resources will be directly on package side,
they can be registered in package provider, in case user will have the need to configure it they can just extend class located inside package.

make registration controllable from outside

Comment on lines +152 to +163
protected function isFirstGlobalBlock(): bool
{
$globalBlocksPath = app_path("Filament/{$this->panel->getId()}/Blocks/Globals");

if (! is_dir($globalBlocksPath)) {
return true;
}

$existingBlocks = glob($globalBlocksPath . '/*.php');

return empty($existingBlocks);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think u will need this if u will remove those two function regarding exporting migrations and block resource

Comment on lines +8 to +11
'global_blocks' => [
'enabled' => true,
'resource' => Redberry\PageBuilderPlugin\Resources\GlobalBlockConfigResource::class,
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some apps have multiple panel providers, move this definitions to plugin registration step, so in case someone has multiple panels and want global blocks in only one of them they can configure it without lot of work

@GigaGiorgadze GigaGiorgadze merged commit 71fa399 into main Sep 11, 2025
@GigaGiorgadze GigaGiorgadze deleted the feat/global-blocks branch March 2, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants