refactoring into clusters

This commit is contained in:
salam committed 2026-05-13 10:10:48 +02:00
1 parent 042a5a8b58
commit 48deb69379
97 files changed
+186 -198

No files matched your search

@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\Pages\ListKontoTextblocks;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\Schemas\KontoTextblockForm;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\Tables\KontoTextblocksTable;
use App\Filament\Clusters\Verwaltung\VerwaltungCluster;
use App\Models\KontoTextblock;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class KontoTextblockResource extends Resource
{
protected static ?string $model = KontoTextblock::class;
protected static ?int $navigationSort = 5;
protected static string|BackedEnum|null $navigationIcon = 'phosphor-article';
protected static ?string $cluster = VerwaltungCluster::class;
protected static ?string $navigationLabel = 'Eigene Textblöcke';
protected static ?string $modelLabel = 'Textblock';
protected static ?string $pluralModelLabel = 'Textblöcke';
public static function form(Schema $schema): Schema
{
return KontoTextblockForm::configure($schema);
}
public static function table(Table $table): Table
{
return KontoTextblocksTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListKontoTextblocks::route('/'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id);
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count();
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks\Pages;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\KontoTextblockResource;
use Filament\Resources\Pages\CreateRecord;
class CreateKontoTextblock extends CreateRecord
{
protected static string $resource = KontoTextblockResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks\Pages;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\KontoTextblockResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditKontoTextblock extends EditRecord
{
protected static string $resource = KontoTextblockResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks\Pages;
use App\Filament\Clusters\Verwaltung\KontoTextblocks\KontoTextblockResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListKontoTextblocks extends ListRecords
{
protected static string $resource = KontoTextblockResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->icon('phosphor-file-plus')
->createAnother(false),
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks\Schemas;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class KontoTextblockForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required(),
// Textarea::make('beschreibung'),
RichEditor::make('textblock')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript'],
]),
])->columns(1);
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Filament\Clusters\Verwaltung\KontoTextblocks\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Support\Enums\FontWeight;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\HtmlString;
class KontoTextblocksTable
{
public static function configure(Table $table): Table
{
return $table
->defaultPaginationPageOption(5)
->columns([
TextColumn::make('name')
->searchable()
->weight(FontWeight::Bold)
->wrap()
->description(function ($record) {
return new HtmlString($record->textblock);
})
->html(),
TextColumn::make('created_at')
->label('Erstellt')
->dateTime('M j, Y'),
])
->recordActions([
EditAction::make()->iconButton(),
DeleteAction::make()->iconButton(),
]);
}
}