feat(Mail template & Membership relationship)
This commit is contained in:
33
database/factories/NotificationTemplateFactory.php
Normal file
33
database/factories/NotificationTemplateFactory.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<NotificationTemplate>
|
||||
*/
|
||||
class NotificationTemplateFactory extends Factory
|
||||
{
|
||||
protected $model = NotificationTemplate::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'identifier' => $this->faker->unique()->slug(2),
|
||||
'name' => $this->faker->sentence(3),
|
||||
'subject' => $this->faker->sentence(),
|
||||
'body' => $this->faker->paragraph(),
|
||||
'variables' => ['name' => 'Nom'],
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function inactive(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'is_active' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notification_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('identifier')->unique();
|
||||
$table->string('name');
|
||||
$table->string('subject');
|
||||
$table->longText('body');
|
||||
$table->json('variables')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notification_templates');
|
||||
}
|
||||
};
|
||||
@@ -3,10 +3,9 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\MemberGroup;
|
||||
use App\Models\Package;
|
||||
use App\Models\Service;
|
||||
use App\Models\User;
|
||||
use App\Models\Package;
|
||||
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
@@ -36,11 +35,11 @@ class DatabaseSeeder extends Seeder
|
||||
]);
|
||||
|
||||
$websiteGroup = MemberGroup::updateOrCreate([
|
||||
'name' => 'Site Web'
|
||||
'name' => 'Site Web',
|
||||
],
|
||||
[
|
||||
'identifier' => 'website',
|
||||
'description' => 'Groupe d\'utilisateurs provenant du site web.'
|
||||
'description' => 'Groupe d\'utilisateurs provenant du site web.',
|
||||
]);
|
||||
|
||||
// Subscription packages
|
||||
@@ -49,20 +48,20 @@ class DatabaseSeeder extends Seeder
|
||||
'identifier' => 'custom',
|
||||
'name' => 'Sur-mesure',
|
||||
'description' => 'Calcul du nombre de mois restant dans l\'année',
|
||||
'price' => '1.00'
|
||||
'price' => '1.00',
|
||||
],
|
||||
[
|
||||
'identifier' => 'one-year',
|
||||
'name' => 'Un an',
|
||||
'description' => '12 mois à compter de la date de validation de l\'adhésion du membre',
|
||||
'price' => '12.00'
|
||||
'price' => '12.00',
|
||||
],
|
||||
[
|
||||
'identifier' => 'two-years',
|
||||
'name' => 'Deux ans',
|
||||
'description' => '24 mois à compter de la date de validation de l\'adhésion du membre',
|
||||
'price' => '24.00'
|
||||
]
|
||||
'price' => '24.00',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($packages as $package) {
|
||||
@@ -112,7 +111,7 @@ class DatabaseSeeder extends Seeder
|
||||
'description' => 'Service d\'hébergement web',
|
||||
'url' => '#',
|
||||
'icon' => 'database',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
@@ -126,6 +125,9 @@ class DatabaseSeeder extends Seeder
|
||||
]);
|
||||
}
|
||||
|
||||
// Notification templates
|
||||
$this->call(NotificationTemplateSeeder::class);
|
||||
|
||||
// JaneDoe
|
||||
$userTest = User::updateOrCreate([
|
||||
'name' => 'JaneDoe',
|
||||
|
||||
29
database/seeders/NotificationTemplateSeeder.php
Normal file
29
database/seeders/NotificationTemplateSeeder.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\NotificationTemplate;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class NotificationTemplateSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
NotificationTemplate::updateOrCreate(
|
||||
['identifier' => 'subscription_expired_phase1'],
|
||||
[
|
||||
'name' => 'Adhésion expirée - Phase 1',
|
||||
'subject' => 'Votre adhésion est expirée',
|
||||
'body' => '<p>Bonjour {member_name},</p>'
|
||||
.'<p>Votre adhésion est arrivée à expiration le {expiry_date}.</p>'
|
||||
.'<p>Pour continuer à profiter de nos services, merci de la renouveler.</p>'
|
||||
.'<p>Merci pour votre confiance.</p>',
|
||||
'variables' => [
|
||||
'member_name' => 'Nom complet du membre',
|
||||
'expiry_date' => 'Date de fin d\'adhésion',
|
||||
],
|
||||
'is_active' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user