Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,24 @@ Manage your Filament app settings with GUI and helpers

## Installation

Open your Laravel project’s `composer.json` and the bellow codes

```text
"repositories": [
{
"type": "vcs",
"url": "https://github.com/gkid-693/filament-settings-hub.git"
}
],
"require": {
"tomatophp/filament-settings-hub": "dev-master"
}

```

```bash
composer require tomatophp/filament-settings-hub
composer update tomatophp/filament-settings-hub --with-all-dependencies
Comment on lines +21 to +37
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove fork-specific installation instructions.

The installation instructions reference a personal fork (gkid-693/filament-settings-hub) rather than the official repository. This should not be merged into the main branch as it will direct users to install from the wrong source.

For the official release, users should install directly via Composer from Packagist:

Replace lines 21-37 with standard installation instructions:

-Open your Laravel project's `composer.json` and the bellow codes
-
-```text
-"repositories": [
-    {
-        "type": "vcs",
-        "url": "https://github.com/gkid-693/filament-settings-hub.git"
-    }
-],
-"require": {
-    "tomatophp/filament-settings-hub": "dev-master"
-}
-
-```
-
 ```bash
-composer update tomatophp/filament-settings-hub --with-all-dependencies
+composer require tomatophp/filament-settings-hub

<details>
<summary>🤖 Prompt for AI Agents</summary>

In README.md around lines 21 to 37, the installation instructions point to a
personal fork (gkid-693) and include a custom composer.json snippet and composer
update command; remove the fork-specific "repositories" block and the dev-master
requirement and replace them with a standard Packagist installation flow: delete
the fork URL and the custom require entry and update the instructions to tell
users to install via composer require tomatophp/filament-settings-hub (and
remove the composer update --with-all-dependencies line), ensuring the README
references the official package on Packagist rather than a VCS fork.


</details>

<!-- This is an auto-generated comment by CodeRabbit -->

```
fadymondy
after publish and migrate settings table please run this command

```bash
Expand All @@ -35,6 +49,7 @@ finally register the plugin on `/app/Providers/Filament/AdminPanelProvider.php`
\TomatoPHP\FilamentSettingsHub\FilamentSettingsHubPlugin::make()
->allowSiteSettings()
->allowSocialMenuSettings()
->allowColorSettings()
)
```

Expand Down
9 changes: 9 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,14 @@
'link' => 'Link',
],
],
'color' => [
'title' => 'System Colors',
'description' => 'Manage your colors',
'form' => [
'primary_color' => 'Primary Color',
'secondary_color' => 'Second Color',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix translation typo: "Second Color" → "Secondary Color".

The label should read "Secondary Color" to match the property name and maintain consistency with "Primary Color" and "Tertiary Color".

Apply this diff:

-                'secondary_color' => 'Second Color',
+                'secondary_color' => 'Secondary Color',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'secondary_color' => 'Second Color',
'secondary_color' => 'Secondary Color',
🤖 Prompt for AI Agents
In resources/lang/en/messages.php around line 44, the translation value for
'secondary_color' is incorrect ("Second Color"); update it to "Secondary Color"
to match the key and remain consistent with "Primary Color" and "Tertiary
Color".

'tertiary_color' => 'Tertiary Color',
],
],
],
];
28 changes: 28 additions & 0 deletions src/FilamentSettingsHubPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use TomatoPHP\FilamentSettingsHub\Facades\FilamentSettingsHub;
use TomatoPHP\FilamentSettingsHub\Pages\ColorSettings;
use TomatoPHP\FilamentSettingsHub\Pages\SettingsHub;
use TomatoPHP\FilamentSettingsHub\Pages\SiteSettings;
use TomatoPHP\FilamentSettingsHub\Pages\SocialMenuSettings;
Expand All @@ -18,6 +19,7 @@ class FilamentSettingsHubPlugin implements Plugin
public static bool | \Closure $allowSiteSettings = true;

public static bool | \Closure $allowSocialMenuSettings = true;
public static bool | \Closure $allowColorSettings = true;

public static bool | \Closure $allowShield = false;

Expand Down Expand Up @@ -49,6 +51,13 @@ public function allowSocialMenuSettings(bool | \Closure $allow = true): static
return $this;
}

public function allowColorSettings(bool | \Closure $allow = true): static
{
self::$allowColorSettings = $allow;

return $this;
}

public function isSiteSettingAllowed(): bool
{
return $this->evaluate(self::$allowSiteSettings);
Expand All @@ -59,6 +68,11 @@ public function isSocialMenuSettingAllowed(): bool
return $this->evaluate(self::$allowSocialMenuSettings);
}

public function isColorSettingAllowed(): bool
{
return $this->evaluate(self::$allowColorSettings);
}

public function isShieldAllowed(): bool
{
return $this->evaluate(self::$allowShield);
Expand All @@ -76,6 +90,10 @@ public function register(Panel $panel): void
$pages[] = SocialMenuSettings::class;
}

if ($this->isColorSettingAllowed()) {
$pages[] = ColorSettings::class;
}

$pages[] = SettingsHub::class;

$panel->pages($pages);
Expand Down Expand Up @@ -105,6 +123,16 @@ public function boot(Panel $panel): void
->group('filament-settings-hub::messages.settings.group');
}

if ($this->isColorSettingAllowed()) {
$settings[] = SettingHold::make()
->page(ColorSettings::class)
->order(0)
->label('filament-settings-hub::messages.settings.color.title')
->icon('heroicon-o-sparkles')
->description('filament-settings-hub::messages.settings.color.description')
->group('filament-settings-hub::messages.settings.group');
}

FilamentSettingsHub::register($settings);
}

Expand Down
69 changes: 69 additions & 0 deletions src/Pages/ColorSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace TomatoPHP\FilamentSettingsHub\Pages;

use BackedEnum;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Forms\Components\ColorPicker;
use Filament\Pages\SettingsPage;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use TomatoPHP\FilamentSettingsHub\Settings\SitesSettings;
use TomatoPHP\FilamentSettingsHub\Traits\UseShield;

class ColorSettings extends SettingsPage
{
use UseShield;

protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-cog';

protected static string $settings = SitesSettings::class;

public function getTitle(): string
{
return trans('filament-settings-hub::messages.settings.color.title');
}

protected function getActions(): array
{
$tenant = Filament::getTenant();
if ($tenant) {
return [
Action::make('back')->action(fn () => redirect()->route('filament.' . filament()->getCurrentPanel()->getId() . '.pages.settings-hub', $tenant))->color('danger')->label(trans('filament-settings-hub::messages.back')),
];
}

return [
Action::make('back')->action(fn () => redirect()->route('filament.' . filament()->getCurrentPanel()->getId() . '.pages.settings-hub'))->color('danger')->label(trans('filament-settings-hub::messages.back')),
];
}

public static function shouldRegisterNavigation(): bool
{
return false;
}

public function form(Schema $schema): Schema
{
return $schema
->schema([
Section::make(trans('filament-settings-hub::messages.settings.color.title'))
->description(trans('filament-settings-hub::messages.settings.color.description'))
->schema([
ColorPicker::make('site_primary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.primary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("primary_color")' : null)
->required(),
ColorPicker::make('site_secondary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.secondary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("secondary_color")' : null)
->required(),
ColorPicker::make('site_tertiary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.tertiary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("tertiary_color")' : null)
->required(),
Comment on lines +54 to +65
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

CRITICAL: Hint property names don't match actual setting keys.

The hints display incorrect property names without the site_ prefix. Since the properties in SitesSettings are named site_primary_color, site_secondary_color, and site_tertiary_color, the hints should reflect the correct setting keys.

Apply this diff to fix the hints:

                        ColorPicker::make('site_primary_color')
                            ->label(trans('filament-settings-hub::messages.settings.color.form.primary_color'))
-                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("primary_color")' : null)
+                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("site_primary_color")' : null)
                            ->required(),
                        ColorPicker::make('site_secondary_color')
                            ->label(trans('filament-settings-hub::messages.settings.color.form.secondary_color'))
-                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("secondary_color")' : null)
+                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("site_secondary_color")' : null)
                            ->required(),
                        ColorPicker::make('site_tertiary_color')
                            ->label(trans('filament-settings-hub::messages.settings.color.form.tertiary_color'))
-                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("tertiary_color")' : null)
+                            ->hint(config('filament-settings-hub.show_hint') ? 'setting("site_tertiary_color")' : null)
                            ->required(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ColorPicker::make('site_primary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.primary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("primary_color")' : null)
->required(),
ColorPicker::make('site_secondary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.secondary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("secondary_color")' : null)
->required(),
ColorPicker::make('site_tertiary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.tertiary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("tertiary_color")' : null)
->required(),
ColorPicker::make('site_primary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.primary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("site_primary_color")' : null)
->required(),
ColorPicker::make('site_secondary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.secondary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("site_secondary_color")' : null)
->required(),
ColorPicker::make('site_tertiary_color')
->label(trans('filament-settings-hub::messages.settings.color.form.tertiary_color'))
->hint(config('filament-settings-hub.show_hint') ? 'setting("site_tertiary_color")' : null)
->required(),
🤖 Prompt for AI Agents
In src/Pages/ColorSettings.php around lines 54 to 65, the ColorPicker hint
strings reference the wrong setting keys (they lack the "site_" prefix); update
each hint to use the correct keys: 'setting("site_primary_color")',
'setting("site_secondary_color")', and 'setting("site_tertiary_color")' while
preserving the existing config('filament-settings-hub.show_hint') conditional
and required() calls.

]),
])->columns(1);
}
}
5 changes: 5 additions & 0 deletions src/Settings/SitesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class SitesSettings extends Settings

public ?array $site_social = [];

public ?string $site_primary_color = null;
public ?string $site_secondary_color = null;
public ?string $site_tertiary_color = null;


public static function group(): string
{
return 'sites';
Expand Down