Conversation
| 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."); | ||
| } |
There was a problem hiding this comment.
no need to include this in a command, this can just be republished like other mgirations
| 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.'); | ||
| } |
There was a problem hiding this comment.
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
| 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); | ||
| } |
There was a problem hiding this comment.
i do not think u will need this if u will remove those two function regarding exporting migrations and block resource
config/page-builder-plugin.php
Outdated
| 'global_blocks' => [ | ||
| 'enabled' => true, | ||
| 'resource' => Redberry\PageBuilderPlugin\Resources\GlobalBlockConfigResource::class, | ||
| ], |
There was a problem hiding this comment.
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
No description provided.