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,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\Pages\ListKontos;
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\Schemas\KontoForm;
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\Tables\KontosTable;
|
||||
use App\Filament\Clusters\Verwaltung\VerwaltungCluster;
|
||||
use App\Models\Konto;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class KontoResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Konto::class;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'lucide-landmark';
|
||||
|
||||
protected static ?string $cluster = VerwaltungCluster::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Konto';
|
||||
|
||||
protected static ?string $modelLabel = 'Konto';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Konto';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return KontoForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return KontosTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListKontos::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->where('id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\KontoResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateKonto extends CreateRecord
|
||||
{
|
||||
protected static string $resource = KontoResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\KontoResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditKonto extends EditRecord
|
||||
{
|
||||
protected static string $resource = KontoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos\Pages;
|
||||
|
||||
use App\Filament\Clusters\Verwaltung\Kontos\KontoResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListKontos extends ListRecords
|
||||
{
|
||||
protected static string $resource = KontoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('agb')
|
||||
->label('AGB\'s')
|
||||
->icon('phosphor-paragraph')
|
||||
->modalContent(view('pages.agb'))
|
||||
->modalSubmitAction(false)
|
||||
->modalCancelAction(fn (Action $action) => $action->label('Schließen')),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos\Schemas;
|
||||
|
||||
use App\Models\Konto;
|
||||
use Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber;
|
||||
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\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class KontoForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make('Rechnungsdaten')
|
||||
->icon('lucide-file-pen-line')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
TextInput::make('company')
|
||||
->label('Firma/Inhaber')
|
||||
->required(),
|
||||
TextInput::make('uid_number')
|
||||
->label('UID Nummer')
|
||||
->rules([new VatNumber])
|
||||
->required(),
|
||||
RichEditor::make('address')->toolbarButtons([
|
||||
['bold', 'italic', 'underline', 'subscript', 'superscript'],
|
||||
])
|
||||
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
|
||||
->label('Adresse')
|
||||
->required(),
|
||||
])->columnSpanFull(),
|
||||
Tab::make('Kontaktperson')
|
||||
->icon('lucide-contact')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
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')
|
||||
->unique(table: Konto::class)
|
||||
->required()
|
||||
->prefixIcon(Heroicon::Envelope),
|
||||
PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
])->columnSpanFull(),
|
||||
// Tab::make('Guthaben')
|
||||
// ->icon('lucide-euro')
|
||||
// ->inlineLabel()
|
||||
// ->schema([
|
||||
// TextInput::make('guthaben')
|
||||
// ->numeric()
|
||||
// ->minValue(1)
|
||||
// ->maxValue(100)
|
||||
// ->label('Guthaben laden')
|
||||
// ->prefixIcon('lucide-coins'),
|
||||
// ])->columnSpanFull(),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Verwaltung\Kontos\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class KontosTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('company')->label('Firma')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->description(fn ($record): HtmlString => new HtmlString($record->address)),
|
||||
TextColumn::make('guthaben')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->color('primary')
|
||||
->description('Gutachten')
|
||||
->alignCenter(),
|
||||
TextColumn::make('abgeschlossen')
|
||||
->size(TextSize::Large)
|
||||
->weight(FontWeight::Bold)
|
||||
->color('success')
|
||||
->description('Gutachten')
|
||||
->alignCenter(),
|
||||
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
// Action::make('Guthaben laden')
|
||||
// ->iconButton()
|
||||
// ->color('gray')
|
||||
// ->icon('heroicon-o-credit-card')
|
||||
// ->schema([
|
||||
// TextInput::make('subject')->required(),
|
||||
// RichEditor::make('body')->required(),
|
||||
// ])
|
||||
// ->action(function (array $data) {}),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user