refactoring into clusters
This commit is contained in:
1 parent
042a5a8b58
commit
48deb69379
97 files changed
+186
-198
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Gutachters;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\Pages\ListGutachters;
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\Schemas\GutachterForm;
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\Tables\GutachtersTable;
|
||||
use App\Filament\Clusters\Verwaltung\VerwaltungCluster;
|
||||
use App\Models\Gutachter;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class GutachterResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Gutachter::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $cluster = VerwaltungCluster::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'lucide-stamp';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'company';
|
||||
|
||||
protected static ?string $navigationLabel = 'Gutachter';
|
||||
|
||||
protected static ?string $modelLabel = 'Gutachter';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Gutachter';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return GutachterForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return GutachtersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListGutachters::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\Gutachters\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\GutachterResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateGutachter extends CreateRecord
|
||||
{
|
||||
protected static string $resource = GutachterResource::class;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Gutachters\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\GutachterResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditGutachter extends EditRecord
|
||||
{
|
||||
protected static string $resource = GutachterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Gutachters\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Gutachters\GutachterResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListGutachters extends ListRecords
|
||||
{
|
||||
protected static string $resource = GutachterResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()
|
||||
->icon('phosphor-file-plus')
|
||||
->createAnother(false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Gutachters\Schemas;
|
||||
|
||||
use App\Actions\Helper\ShowHelp;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class GutachterForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make('Gutachter')
|
||||
->icon('lucide-stamp')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('company')
|
||||
->belowContent([
|
||||
'Kann als Platzhalter "###GUTACHTER###" im Gutachten verwendet werden.',
|
||||
])
|
||||
->label('Firma')
|
||||
->required(),
|
||||
TextInput::make('title')
|
||||
->label('Title')
|
||||
->required(),
|
||||
Select::make('gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label('E-Mail')
|
||||
->required()
|
||||
->prefixIcon(Heroicon::Envelope),
|
||||
PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
]),
|
||||
Tab::make('Logo')
|
||||
->icon('phosphor-image')
|
||||
->schema([
|
||||
Checkbox::make('logo_anzeigen')
|
||||
->label('Das Logo im Gutachten verwenden')
|
||||
->columnSpanFull()
|
||||
->live(),
|
||||
FileUpload::make('logo')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('gutachter-logo')
|
||||
->maxSize(3072) // 3MB limit
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->visibility('public')
|
||||
->label('Logo')
|
||||
->afterLabel([ShowHelp::show('logo_am_deckblatt')])
|
||||
->columnSpanFull(),
|
||||
Radio::make('logo_align')
|
||||
->Label('Position')
|
||||
->default('right')
|
||||
->options([
|
||||
'left' => 'Links',
|
||||
'center' => 'Zentriert',
|
||||
'right' => 'Rechts',
|
||||
]),
|
||||
TextInput::make('logo_height')
|
||||
->hidden(fn (Get $get): bool => ! $get('logo_anzeigen'))
|
||||
->belowLabel('190mm ist die halbe Breite der Seite')
|
||||
->numeric()
|
||||
->default(70)
|
||||
->minValue(20)
|
||||
->maxValue(100)
|
||||
->label('Logo Breite')
|
||||
->required()
|
||||
->suffix('mm'),
|
||||
])->columns(2),
|
||||
Tab::make('Anzeige am Deckblatt')
|
||||
->icon('lucide-contact')
|
||||
->schema([
|
||||
Checkbox::make('text_anzeigen')
|
||||
->label('Diesen Text anzeigen')
|
||||
->columnSpanFull(),
|
||||
RichEditor::make('referenz_formatting')
|
||||
->json()
|
||||
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
|
||||
->toolbarButtons([
|
||||
['bold', 'italic', 'underline', 'clearFormatting'],
|
||||
['h3', 'alignStart', 'alignCenter', 'alignEnd', 'textColor'],
|
||||
])
|
||||
->textColors([
|
||||
'#fb2c36' => 'Rot',
|
||||
'#ff6900' => 'Orange',
|
||||
'#fe9a00' => 'Bernstein',
|
||||
'#f0b100' => 'Gelb',
|
||||
'#7ccf00' => 'Limette',
|
||||
'#00c950' => 'Grün',
|
||||
'#00bc7d' => 'Smaragd',
|
||||
'#00bba7' => 'Blaugrün',
|
||||
'#00b8db' => 'Cyan',
|
||||
'#00a6f4' => 'Himmelblau',
|
||||
'#2b7fff' => 'Blau',
|
||||
'#615fff' => 'Indigo',
|
||||
'#8e51ff' => 'Violett',
|
||||
'#ad46ff' => 'Lila',
|
||||
'#e12afb' => 'Fuchisa',
|
||||
'#f6339a' => 'Rosa',
|
||||
'#ff2056' => 'Rose',
|
||||
'#a6a09b' => 'Hellgrau',
|
||||
'#314158' => 'Dunkelgrau',
|
||||
])
|
||||
->label('Gutachter am Deckblatt')
|
||||
->afterLabel([ShowHelp::show('gutachter_am_deckblatt')])
|
||||
->required(),
|
||||
]),
|
||||
|
||||
Tab::make('digitale_signatur')
|
||||
->label('Digitale Signatur')
|
||||
->icon('phosphor-stamp')
|
||||
->schema([
|
||||
FileUpload::make('digitale_signatur_stempel')
|
||||
->label('Bild vom Stempel')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('gutachter-stempel')
|
||||
->maxSize(3072) // 3MB limit
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->visibility('public'),
|
||||
])->columns(2),
|
||||
Tab::make('Farben')
|
||||
->icon('phosphor-palette')
|
||||
->schema([
|
||||
ColorPicker::make('deckblatt_bg')->label('Deckblatt')
|
||||
->belowContent('Farbe des Hintergrundes'),
|
||||
ColorPicker::make('schmuckfarbe_header')->label('Überschriften')
|
||||
->belowContent('Farbe des Hintergrundes'),
|
||||
ColorPicker::make('farbe_borders')->label('Rahmen')
|
||||
->belowContent('Farbe von Rahmen und Begrenzungen'),
|
||||
])->columns(2),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Gutachters\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class GutachtersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
ImageColumn::make('logo')->disk('public'),
|
||||
TextColumn::make('company')->label('Firmenmame')->searchable(),
|
||||
// TextColumn::make('gender')->label('Geschlecht'),
|
||||
// TextColumn::make('title')->label('Title'),
|
||||
// TextColumn::make('name')->searchable(),
|
||||
ImageColumn::make('digitale_signatur_stempel')
|
||||
->alignCenter()
|
||||
->label('Digitale Signatur')
|
||||
->disk('public'),
|
||||
TextColumn::make('email')->copyable()->label('E-Mail')->searchable(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user