feat(Mail template & Membership relationship)
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates;
|
||||
|
||||
use App\Filament\Resources\NotificationTemplates\Pages\CreateNotificationTemplate;
|
||||
use App\Filament\Resources\NotificationTemplates\Pages\EditNotificationTemplate;
|
||||
use App\Filament\Resources\NotificationTemplates\Pages\ListNotificationTemplates;
|
||||
use App\Filament\Resources\NotificationTemplates\Schemas\NotificationTemplateForm;
|
||||
use App\Filament\Resources\NotificationTemplates\Tables\NotificationTemplatesTable;
|
||||
use App\Models\NotificationTemplate;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class NotificationTemplateResource extends Resource
|
||||
{
|
||||
protected static ?string $model = NotificationTemplate::class;
|
||||
|
||||
protected static string|null|\UnitEnum $navigationGroup = 'Administration';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedEnvelope;
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return NotificationTemplate::getAttributeLabel('singular_name');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return NotificationTemplate::getAttributeLabel('plural_name');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return NotificationTemplateForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return NotificationTemplatesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListNotificationTemplates::route('/'),
|
||||
'create' => CreateNotificationTemplate::route('/create'),
|
||||
'edit' => EditNotificationTemplate::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\NotificationTemplates\NotificationTemplateResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateNotificationTemplate extends CreateRecord
|
||||
{
|
||||
protected static string $resource = NotificationTemplateResource::class;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\NotificationTemplates\NotificationTemplateResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditNotificationTemplate extends EditRecord
|
||||
{
|
||||
protected static string $resource = NotificationTemplateResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\NotificationTemplates\NotificationTemplateResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListNotificationTemplates extends ListRecords
|
||||
{
|
||||
protected static string $resource = NotificationTemplateResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates\Schemas;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class NotificationTemplateForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(fn (?NotificationTemplate $record) => $record?->name ?? NotificationTemplate::getAttributeLabel('name'))
|
||||
->afterHeader([
|
||||
Toggle::make('is_active')
|
||||
->label(NotificationTemplate::getAttributeLabel('is_active'))
|
||||
->default(true),
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label(NotificationTemplate::getAttributeLabel('name'))
|
||||
->required(),
|
||||
TextInput::make('identifier')
|
||||
->label(NotificationTemplate::getAttributeLabel('identifier'))
|
||||
->required()
|
||||
->disabledOn('edit'),
|
||||
TextInput::make('subject')
|
||||
->label(NotificationTemplate::getAttributeLabel('subject'))
|
||||
->required()
|
||||
->helperText('Variables : {member_name}, {expiry_date}'),
|
||||
RichEditor::make('body')
|
||||
->label(NotificationTemplate::getAttributeLabel('body'))
|
||||
->required()
|
||||
->helperText('Variables : {member_name}, {expiry_date}')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NotificationTemplates\Tables;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class NotificationTemplatesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(NotificationTemplate::getAttributeLabel('name'))
|
||||
->searchable(),
|
||||
TextColumn::make('identifier')
|
||||
->label(NotificationTemplate::getAttributeLabel('identifier'))
|
||||
->searchable(),
|
||||
TextColumn::make('subject')
|
||||
->label(NotificationTemplate::getAttributeLabel('subject'))
|
||||
->searchable(),
|
||||
IconColumn::make('is_active')
|
||||
->label(NotificationTemplate::getAttributeLabel('is_active'))
|
||||
->boolean(),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user