Possibility to set Mailtemplates to draft

This commit is contained in:
Anna-Sara Sélea 2026-05-18 06:50:12 +02:00
parent c5bfb28eb8
commit ee718a3a7d
4 changed files with 31 additions and 7 deletions

View file

@ -5,6 +5,7 @@ namespace App\Filament\Resources\Mailtemplates\Schemas;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
use Filament\Forms\Components\MarkdownEditor;
use DiscoveryDesign\FilamentGaze\Forms\Components\GazeBanner;
@ -21,13 +22,13 @@ class MailtemplateForm
TextInput::make('title')
->required()
->columnSpanFull(),
TextInput::make('type')
->label('Greeting')
->required()
->columnSpanFull(),
MarkdownEditor::make('content')
->required()
->columnSpanFull(),
Toggle::make('draft')
->default(false)
->onColor('warning')
->columnSpanFull(),
]);
}
}

View file

@ -158,7 +158,7 @@ class ParticipantsTable
->schema([
Select::make('mailtemplate')
->label('Mailtemplate')
->options(Mailtemplate::all()->pluck('title', 'id'))
->options(Mailtemplate::where('draft', false)->pluck('title', 'id'))
])
->action(function (array $data, Participant $record) {
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();
@ -176,7 +176,7 @@ class ParticipantsTable
->schema([
Select::make('mailtemplate')
->label('Mailtemplate')
->options(Mailtemplate::all()->pluck('title', 'id'))
->options(Mailtemplate::where('draft', false)->pluck('title', 'id'))
])
->action(function (array $data, Participant $record) {
$mailContent = Mailtemplate::where('id', $data['mailtemplate'])->get();

View file

@ -9,6 +9,7 @@ class Mailtemplate extends Model
protected $fillable = [
'title',
'content',
'type'
'type',
'draft'
];
}

View file

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('mailtemplates', function (Blueprint $table) {
$table->boolean('draft')->default(false)->after('content');
});
}
public function down(): void
{
Schema::table('mailtemplates', function (Blueprint $table) {
$table->dropColumn('draft');
});
}
};