Add DatabaseSeeder and enhance settings management: Created DatabaseSeeder to seed initial data, including a test user. Updated ListSettings page to support group filtering and added new settings groups in localization files. Enhanced SettingForm and SettingsTable to accommodate new group options and improved UI for settings management.

This commit is contained in:
Ümit Tunç
2025-10-29 16:58:05 -03:00
parent 1791108b1e
commit 3669e17119
9 changed files with 1350 additions and 64 deletions
@@ -3,18 +3,37 @@
namespace App\Filament\Admin\Resources\Settings\Pages;
use App\Filament\Admin\Resources\Settings\SettingResource;
use App\Filament\Admin\Resources\Settings\Tables\SettingsTable;
use Filament\Actions\CreateAction;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Illuminate\Contracts\Support\Htmlable;
class ListSettings extends ListRecords
class ListSettings extends ListRecords implements HasForms
{
use InteractsWithForms;
protected static string $resource = SettingResource::class;
public ?string $activeGroup = null;
public function getView(): string
{
return 'filament.admin.resources.settings.pages.list-settings';
}
public function getTitle(): string
{
return __('settings.title');
}
public function getHeading(): string | Htmlable
{
return __('settings.title');
}
protected function getHeaderActions(): array
{
return [
@@ -22,4 +41,78 @@ class ListSettings extends ListRecords
->label(__('settings.create')),
];
}
public function mount(): void
{
parent::mount();
// Query string'den activeGroup' 별 al, yoksa tüm ayarları göster (null)
$this->activeGroup = request()->query('group', null);
}
public function getGroups(): \Illuminate\Support\Collection
{
return \App\Models\Setting::whereNull('deleted_at')
->select('group')
->distinct()
->orderBy('group')
->pluck('group')
->mapWithKeys(function ($group) {
return [$group => __("settings.group_{$group}")];
});
}
public function setActiveGroup(?string $group): void
{
$this->activeGroup = $group;
}
protected function getTableQuery(): \Illuminate\Database\Eloquent\Builder
{
$query = parent::getTableQuery();
// Eğer bir grup seçildiyse filtrele
if ($this->activeGroup) {
$query->where('group', $this->activeGroup);
}
return $query;
}
protected function getGroupIcon(?string $group): string
{
if (!$group) {
return 'heroicon-o-squares-2x2';
}
return match($group) {
'general' => 'heroicon-o-cog-6-tooth',
'theme' => 'heroicon-o-paint-brush',
'localization' => 'heroicon-o-language',
'email' => 'heroicon-o-envelope',
'seo' => 'heroicon-o-magnifying-glass',
'social' => 'heroicon-o-share',
'security' => 'heroicon-o-shield-check',
'upload' => 'heroicon-o-cloud-arrow-up',
'payment' => 'heroicon-o-credit-card',
'notification' => 'heroicon-o-bell',
'cache' => 'heroicon-o-arrow-path',
'api' => 'heroicon-o-code-bracket',
'logging' => 'heroicon-o-document-text',
'performance' => 'heroicon-o-bolt',
'integration' => 'heroicon-o-puzzle-piece',
default => 'heroicon-o-squares-2x2',
};
}
protected function getGroupCount(?string $group): int
{
if (!$group) {
return \App\Models\Setting::whereNull('deleted_at')->count();
}
return \App\Models\Setting::where('group', $group)
->whereNull('deleted_at')
->count();
}
}
@@ -92,12 +92,20 @@ class SettingForm
->required()
->options([
'general' => __('settings.group_general'),
'theme' => __('settings.group_theme'),
'localization' => __('settings.group_localization'),
'email' => __('settings.group_email'),
'seo' => __('settings.group_seo'),
'social' => __('settings.group_social'),
'security' => __('settings.group_security'),
'upload' => __('settings.group_upload'),
'payment' => __('settings.group_payment'),
'notification' => __('settings.group_notification'),
'cache' => __('settings.group_cache'),
'api' => __('settings.group_api'),
'logging' => __('settings.group_logging'),
'performance' => __('settings.group_performance'),
'integration' => __('settings.group_integration'),
'other' => __('settings.group_other'),
])
->default('general'),
@@ -88,19 +88,6 @@ class SettingsTable
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
SelectFilter::make('group')
->label(__('settings.filter_group'))
->options([
'general' => __('settings.group_general'),
'email' => __('settings.group_email'),
'seo' => __('settings.group_seo'),
'social' => __('settings.group_social'),
'security' => __('settings.group_security'),
'payment' => __('settings.group_payment'),
'notification' => __('settings.group_notification'),
'other' => __('settings.group_other'),
]),
SelectFilter::make('type')
->label(__('settings.filter_type'))
->options([