From 7024ee87c95028d610349eb9563024ea22d42e81 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Sat, 3 Apr 2021 20:15:02 +0300 Subject: [PATCH] functional --- .../AdvsModuleNotificationsTemplateSeeder.php | 52 +++++++++---------- ...ofileModuleNotificationsTemplateSeeder.php | 49 ++++++++--------- 2 files changed, 47 insertions(+), 54 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Notifications/AdvsModuleNotificationsTemplateSeeder.php b/addons/default/visiosoft/advs-module/src/Notifications/AdvsModuleNotificationsTemplateSeeder.php index 7678bece1..28b5088a8 100644 --- a/addons/default/visiosoft/advs-module/src/Notifications/AdvsModuleNotificationsTemplateSeeder.php +++ b/addons/default/visiosoft/advs-module/src/Notifications/AdvsModuleNotificationsTemplateSeeder.php @@ -10,10 +10,9 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder public function run() { if (is_module_installed('visiosoft.module.notifications')) { - $template_repo = app(TemplateRepositoryInterface::class); - if (!$template_repo->findBySlug(Str::slug('Created Ad', '_'))) { - $template_repo->create([ + $templates = [ + [ 'en' => [ 'message' => '

 Your post {name} has been created successfully.

', 'name' => 'Created Ad', @@ -22,12 +21,8 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'advs', 'slug' => Str::slug('Created Ad', '_') - ]); - } - - - if (!$template_repo->findBySlug(Str::slug('Approved Ad', '_'))) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => '

Your ad for {name} has been approved.

', 'name' => 'Approved Ad', @@ -36,12 +31,8 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'advs', 'slug' => Str::slug('Approved Ad', '_') - ]); - } - - - if (!$template_repo->findBySlug(Str::slug('Declined Ad', '_'))) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => '

Your {name} ad was rejected because it does not comply with the posting rules.

', 'name' => 'Declined Ad', @@ -50,12 +41,8 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'advs', 'slug' => Str::slug('Declined Ad', '_') - ]); - } - - - if (!$template_repo->findBySlug(Str::slug('Pending User Ad', '_'))) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => '

You must confirm your {name} posting to be published.

', 'name' => 'Pending User Ad', @@ -64,12 +51,8 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'advs', 'slug' => Str::slug('Pending User Ad', '_') - ]); - } - - - if (!$template_repo->findBySlug(Str::slug('Pending Ad', '_'))) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => '

Your {name} post is checked by our editors.

', 'name' => 'Pending Ad', @@ -78,9 +61,22 @@ class AdvsModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'advs', 'slug' => Str::slug('Pending Ad', '_') - ]); + ] + ]; + + foreach ($templates as $template) { + $this->createTemplate($template); } } } + + public function createTemplate($params) + { + $template_repo = app(TemplateRepositoryInterface::class); + + if (!$template_repo->findBySlug($params['slug'])) { + $template_repo->create($params); + } + } } \ No newline at end of file diff --git a/addons/default/visiosoft/profile-module/src/Notifications/ProfileModuleNotificationsTemplateSeeder.php b/addons/default/visiosoft/profile-module/src/Notifications/ProfileModuleNotificationsTemplateSeeder.php index f32752845..f530b2a75 100644 --- a/addons/default/visiosoft/profile-module/src/Notifications/ProfileModuleNotificationsTemplateSeeder.php +++ b/addons/default/visiosoft/profile-module/src/Notifications/ProfileModuleNotificationsTemplateSeeder.php @@ -10,11 +10,9 @@ class ProfileModuleNotificationsTemplateSeeder extends Seeder public function run() { if (is_module_installed('visiosoft.module.notifications')) { - $template_repo = app(TemplateRepositoryInterface::class); - - if (!$template_repo->findBySlug(Str::slug('Registered User', '_'))) { - $template_repo->create([ + $templates = [ + [ 'en' => [ 'message' => '

Your membership is activated.
Email:{email}

', 'name' => 'Registered User', @@ -23,13 +21,8 @@ class ProfileModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'users', 'slug' => Str::slug('Registered User', '_') - ]); - - } - - - if (!$template_repo->findBySlug(Str::slug('New User Welcome', '_'))) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => ' @@ -94,13 +87,8 @@ class ProfileModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'users', 'slug' => Str::slug('New User Welcome', '_') - ]); - } - - - if (!$template_repo->findBySlug(Str::slug('Password Forget', '_'))) { - - $template_repo->create([ + ], + [ 'en' => [ 'message' => ' @@ -165,12 +153,8 @@ class ProfileModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'users', 'slug' => Str::slug('Password Forget', '_') - ]); - } - - - if (!$template_repo->findBySlug('password_changed')) { - $template_repo->create([ + ], + [ 'en' => [ 'message' => '

Your password has been changed

', 'name' => 'Password Changed', @@ -179,9 +163,22 @@ class ProfileModuleNotificationsTemplateSeeder extends Seeder ], 'stream' => 'users', 'slug' => 'password_changed' - ]); - } + ], + ]; + + foreach ($templates as $template) { + $this->createTemplate($template); + } + } + } + + public function createTemplate($params) + { + $template_repo = app(TemplateRepositoryInterface::class); + + if (!$template_repo->findBySlug($params['slug'])) { + $template_repo->create($params); } } } \ No newline at end of file