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,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages;
|
||||
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\Pages\ListMailVorlages;
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\Schemas\MailVorlageForm;
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\Tables\MailVorlagesTable;
|
||||
use App\Filament\Clusters\Newsletter\NewsletterCluster;
|
||||
use App\Models\MailVorlage;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MailVorlageResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MailVorlage::class;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static ?string $cluster = NewsletterCluster::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentText;
|
||||
|
||||
protected static ?string $navigationLabel = 'Mail Vorlagen';
|
||||
|
||||
protected static ?string $modelLabel = 'Mail Vorlagen';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Mail Vorlagen';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return MailVorlageForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return MailVorlagesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListMailVorlages::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages\Pages;
|
||||
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\MailVorlageResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMailVorlage extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MailVorlageResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages\Pages;
|
||||
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\MailVorlageResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMailVorlage extends EditRecord
|
||||
{
|
||||
protected static string $resource = MailVorlageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages\Pages;
|
||||
|
||||
use App\Filament\Clusters\Newsletter\MailVorlages\MailVorlageResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMailVorlages extends ListRecords
|
||||
{
|
||||
protected static string $resource = MailVorlageResource::class;
|
||||
|
||||
// protected function getTableRecordsPerPageSelectOptions(): array
|
||||
// {
|
||||
// return [1];
|
||||
// }
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()->createAnother(false),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages\Schemas;
|
||||
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class MailVorlageForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('titel')
|
||||
->suffix('Nur zur Kennung')
|
||||
->required(),
|
||||
TextInput::make('subjekt')
|
||||
->label('Betreff')
|
||||
->required(),
|
||||
RichEditor::make('inhalt')
|
||||
->required()
|
||||
->aboveContent(new HtmlString('<div class="text-xs text-blue-600">Im Text können <b>Vornamen</b>, <b>Nachnamen</b> und <b>Herr/Frau</b> des Empfänger/der Empfängerin mit den Platzhaltern ###vorname###, ###nachname### und ###geschlecht### ersetzen werden. <br><br></div>'))
|
||||
->toolbarButtons([
|
||||
['bold', 'italic', 'underline', 'strike', 'code', 'small', 'highlight'],
|
||||
['undo', 'redo'],
|
||||
]),
|
||||
RichEditor::make('unterschrift')
|
||||
->toolbarButtons([
|
||||
['bold', 'italic'],
|
||||
['undo', 'redo'],
|
||||
]),
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Newsletter\MailVorlages\Tables;
|
||||
|
||||
use App\Models\MailVorlage;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\Layout\Split;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class MailVorlagesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Split::make([
|
||||
Stack::make([
|
||||
TextColumn::make('subjekt')
|
||||
->size(TextSize::Medium),
|
||||
TextColumn::make('inhalt')
|
||||
->label('E-Mail Vorlage')
|
||||
->extraAttributes(['class' => 'tiptap'])
|
||||
->markdown()
|
||||
->wrap(),
|
||||
TextColumn::make('unterschrift')
|
||||
->markdown(),
|
||||
])->space(10),
|
||||
]),
|
||||
])
|
||||
->paginated(false)
|
||||
->filters([
|
||||
Filter::make('vorlagen_id')
|
||||
->schema([
|
||||
Select::make('vorlagen_id')
|
||||
->searchable()
|
||||
->hiddenLabel()
|
||||
->preload()
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->options(function (): array {
|
||||
return MailVorlage::pluck('titel', 'id')->toArray();
|
||||
}),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['vorlagen_id'],
|
||||
fn (Builder $query, $vorlagen_id): Builder => $query->where('id', $vorlagen_id),
|
||||
);
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->persistFiltersInSession()
|
||||
->filtersResetActionPosition(null)
|
||||
->hiddenFilterIndicators()
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user