language files combined, settings fixed, "new" badge integrated

This commit is contained in:
2025-08-01 23:34:41 +02:00
parent b2968f203d
commit 80873877c1
44 changed files with 1319 additions and 358 deletions

View File

@@ -5,6 +5,8 @@ namespace App\Filament\Resources\AiModelResource\Pages;
use App\Filament\Resources\AiModelResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
class ListAiModels extends ListRecords
{
@@ -16,4 +18,35 @@ class ListAiModels extends ListRecords
Actions\CreateAction::make(),
];
}
protected function shouldPersistTableFiltersInSession(): bool
{
return true;
}
protected function shouldPersistTableSortInSession(): bool
{
return true;
}
protected function shouldPersistTableSearchInSession(): bool
{
return true;
}
protected function paginateTableQuery(Builder $query): Paginator
{
$paginator = parent::paginateTableQuery($query);
return $paginator;
}
public function updatedTablePage($page)
{
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
}
protected function getTableQueryStringIdentifier(): ?string
{
return 'ai-models-table';
}
}

View File

@@ -5,6 +5,8 @@ namespace App\Filament\Resources\ApiProviderResource\Pages;
use App\Filament\Resources\ApiProviderResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
class ListApiProviders extends ListRecords
{
@@ -16,4 +18,35 @@ class ListApiProviders extends ListRecords
Actions\CreateAction::make(),
];
}
protected function shouldPersistTableFiltersInSession(): bool
{
return true;
}
protected function shouldPersistTableSortInSession(): bool
{
return true;
}
protected function shouldPersistTableSearchInSession(): bool
{
return true;
}
protected function paginateTableQuery(Builder $query): Paginator
{
$paginator = parent::paginateTableQuery($query);
return $paginator;
}
public function updatedTablePage($page)
{
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
}
protected function getTableQueryStringIdentifier(): ?string
{
return 'api-providers-table';
}
}

View File

@@ -31,6 +31,9 @@ class ImageResource extends Resource
->required()
->image()
->directory('uploads'),
Forms\Components\Toggle::make('is_public')
->label(__('Publicly Visible'))
->default(false),
]);
}

View File

@@ -5,6 +5,8 @@ namespace App\Filament\Resources\ImageResource\Pages;
use App\Filament\Resources\ImageResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
class ListImages extends ListRecords
{
@@ -16,4 +18,35 @@ class ListImages extends ListRecords
Actions\CreateAction::make(),
];
}
protected function shouldPersistTableFiltersInSession(): bool
{
return true;
}
protected function shouldPersistTableSortInSession(): bool
{
return true;
}
protected function shouldPersistTableSearchInSession(): bool
{
return true;
}
protected function paginateTableQuery(Builder $query): Paginator
{
$paginator = parent::paginateTableQuery($query);
return $paginator;
}
public function updatedTablePage($page)
{
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
}
protected function getTableQueryStringIdentifier(): ?string
{
return 'images-table';
}
}

View File

@@ -12,18 +12,31 @@ use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Fieldset;
class SettingResource extends Resource
{
protected static ?string $model = Setting::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationIcon = 'heroicon-o-cog';
public static function form(Form $form): Form
{
return $form
->schema([
//
Forms\Components\TextInput::make('key')
->label(__('Key'))
->required()
->maxLength(255)
->hiddenOn('edit'),
Forms\Components\Fieldset::make()
->label(fn (?Setting $record) => $record ? $record->key : __('New Setting'))
->schema([
TextInput::make('value')
->label(__('Value'))
->disableLabel()
])
]);
}
@@ -31,7 +44,8 @@ class SettingResource extends Resource
{
return $table
->columns([
//
Tables\Columns\TextColumn::make('key')->label(__('Key'))->searchable()->sortable(),
Tables\Columns\TextColumn::make('value')->label(__('Value'))->searchable()->sortable(),
])
->filters([
//
@@ -39,6 +53,7 @@ class SettingResource extends Resource
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),

View File

@@ -1,64 +0,0 @@
<?php
namespace App\Filament\Resources\SettingResource\Pages;
use App\Filament\Resources\SettingResource;
use App\Models\Setting;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Illuminate\Database\Eloquent\Model;
class Settings extends Page implements HasForms
{
use InteractsWithForms;
protected static string $resource = SettingResource::class;
protected static ?string $navigationIcon = 'heroicon-o-cog';
protected static ?string $navigationGroup = 'Settings';
protected static ?string $navigationLabel = 'Global Settings';
protected static ?string $slug = 'global-settings';
protected static string $view = 'filament.resources.setting-resource.pages.settings';
public ?array $data = [];
public function mount(): void
{
$this->form->fill(
collect(Setting::all())
->mapWithKeys(fn (Setting $setting) => [$setting->key => $setting->value])
->all()
);
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('gallery_heading')
->label(__('settings.gallery_heading')),
])
->statePath('data')
->model(Setting::class);
}
public function submit(): void
{
foreach ($this->form->getState() as $key => $value) {
Setting::updateOrCreate(['key' => $key], ['value' => $value]);
}
Notification::make()
->title(__('settings.saved_successfully'))
->success()
->send();
}
}

View File

@@ -110,9 +110,7 @@ class StyleResource extends Resource
])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
])
->persistFiltersInSession()
->persistSortInSession();
]);
}
public static function getRelations(): array

View File

@@ -5,6 +5,8 @@ namespace App\Filament\Resources\StyleResource\Pages;
use App\Filament\Resources\StyleResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
class ListStyles extends ListRecords
{
@@ -16,4 +18,35 @@ class ListStyles extends ListRecords
Actions\CreateAction::make(),
];
}
protected function shouldPersistTableFiltersInSession(): bool
{
return true;
}
protected function shouldPersistTableSortInSession(): bool
{
return true;
}
protected function shouldPersistTableSearchInSession(): bool
{
return true;
}
protected function paginateTableQuery(Builder $query): Paginator
{
$paginator = parent::paginateTableQuery($query);
return $paginator;
}
public function updatedTablePage($page)
{
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
}
protected function getTableQueryStringIdentifier(): ?string
{
return 'styles-table';
}
}

View File

@@ -27,24 +27,50 @@ class UserResource extends Resource
{
return $form
->schema([
TextInput::make('name')
->label(__('filament.resource.user.form.name'))
->required()
->maxLength(255),
TextInput::make('email')
->label(__('filament.resource.user.form.email'))
->email()
->required()
->maxLength(255),
TextInput::make('password')
->label(__('filament.resource.user.form.password'))
->password()
->required()
->maxLength(255),
Select::make('role_id')
->relationship('role', 'name')
->label(__('filament.resource.user.form.role'))
->required(),
Forms\Components\Section::make('User Details')
->schema([
TextInput::make('name')
->label(__('filament.resource.user.form.name'))
->required()
->maxLength(255),
TextInput::make('email')
->label(__('filament.resource.user.form.email'))
->email()
->required()
->maxLength(255),
TextInput::make('password')
->label(__('filament.resource.user.form.password'))
->password()
->dehydrateStateUsing(fn (string $state): string => bcrypt($state))
->dehydrated(fn (?string $state): bool => filled($state))
->required(fn (string $operation): bool => $operation === 'create')
->maxLength(255),
Select::make('role_id')
->relationship('role', 'name')
->label(__('filament.resource.user.form.role'))
->required(),
])->columns(2),
Forms\Components\Section::make('Preferences')
->schema([
Forms\Components\Toggle::make('email_notifications_enabled')
->label(__('Email Notifications'))
->default(true),
Select::make('theme_preference')
->label(__('Theme'))
->options([
'light' => 'Light',
'dark' => 'Dark',
])
->default('light'),
Select::make('locale')
->label(__('Language'))
->options([
'en' => 'English',
'de' => 'Deutsch',
])
->default('en'),
])->columns(2),
]);
}

View File

@@ -5,6 +5,8 @@ namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;
class ListUsers extends ListRecords
{
@@ -16,4 +18,35 @@ class ListUsers extends ListRecords
Actions\CreateAction::make(),
];
}
protected function shouldPersistTableFiltersInSession(): bool
{
return true;
}
protected function shouldPersistTableSortInSession(): bool
{
return true;
}
protected function shouldPersistTableSearchInSession(): bool
{
return true;
}
protected function paginateTableQuery(Builder $query): Paginator
{
$paginator = parent::paginateTableQuery($query);
return $paginator;
}
public function updatedTablePage($page)
{
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
}
protected function getTableQueryStringIdentifier(): ?string
{
return 'users-table';
}
}