Skip to content

Commit c9d29b6

Browse files
author
Muammer Top
authored
Merge pull request #1 from openclassify/erhan
Added 'Welcome Mail' event for ocify and openclassify.
2 parents bf2c0b1 + d86c644 commit c9d29b6

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed

resources/lang/en/notification.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@
3939
'instructions' => 'Your account has been activated.',
4040
'button' => 'Login',
4141
],
42+
'welcome_user' => [
43+
'subject' => 'Welcome !',
44+
'greeting' => 'Welcome :display_name !',
45+
'instructions' => 'This site is your new companion on the road to online success.
46+
Use our no-code builder to create the website or online store of your dreams.',
47+
'button' => 'Get Started',
48+
]
4249
];

resources/lang/tr/notification.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,11 @@
3939
'instructions' => 'Hesabınız aktive edildi.',
4040
'button' => 'Oturum aç',
4141
],
42+
'welcome_user' => [
43+
'subject' => 'Hoşgeldiniz !',
44+
'greeting' => 'Hoşgeldiniz :display_name !',
45+
'instructions' => 'Online satışlarda başarıya giden yolunuz biz olalım.
46+
Hayallerinizdeki online mağazayı kurmak için Ocify kullanın.',
47+
'button' => 'Hemen Başla',
48+
]
4249
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "streams::notifications/email" %}

src/User/Command/WelcomeUser.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php namespace Anomaly\UsersModule\User\Command;
2+
3+
use Anomaly\UsersModule\User\Contract\UserInterface;
4+
use Illuminate\Foundation\Bus\DispatchesJobs;
5+
6+
class WelcomeUser
7+
{
8+
use DispatchesJobs;
9+
10+
/**
11+
* The user instance.
12+
*
13+
* @var UserInterface
14+
*/
15+
protected $user;
16+
17+
/**
18+
* The redirect path.
19+
*
20+
* @var string
21+
*/
22+
protected $redirect;
23+
24+
/**
25+
* Create a new SendWelcomeEmail instance.
26+
*
27+
* @param UserInterface $user
28+
* @param string $redirect
29+
*/
30+
public function __construct(UserInterface $user, $redirect = '/')
31+
{
32+
$this->user = $user;
33+
$this->redirect = $redirect;
34+
}
35+
36+
/**
37+
* Handle the command.
38+
*
39+
* @return bool
40+
*/
41+
public function handle()
42+
{
43+
$this->user->notify(new \Anomaly\UsersModule\User\Notification\WelcomeUser($this->redirect));
44+
}
45+
}

src/User/Notification/WelcomeUser.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php namespace Anomaly\UsersModule\User\Notification;
2+
3+
use Anomaly\Streams\Platform\Notification\Message\MailMessage;
4+
use Anomaly\UsersModule\User\Contract\UserInterface;
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Notifications\Notification;
8+
9+
10+
class WelcomeUser extends Notification implements ShouldQueue
11+
{
12+
13+
use Queueable;
14+
15+
16+
public $redirect;
17+
18+
19+
public function __construct($redirect = '/')
20+
{
21+
$this->redirect = $redirect;
22+
}
23+
24+
public function via(UserInterface $notifiable)
25+
{
26+
return ['mail'];
27+
}
28+
29+
30+
public function toMail(UserInterface $notifiable)
31+
{
32+
$data = $notifiable->toArray();
33+
34+
return (new MailMessage())
35+
->view('anomaly.module.users::notifications.welcome_user')
36+
->subject(trans('anomaly.module.users::notification.welcome_user.subject', $data))
37+
->greeting(trans('anomaly.module.users::notification.welcome_user.greeting', $data))
38+
->line(trans('anomaly.module.users::notification.welcome_user.instructions', $data))
39+
->action(
40+
trans('anomaly.module.users::notification.welcome_user.button', $data),
41+
$this->redirect != '/' ?$this->redirect: 'https://'.setting_value('streams::domain', 'ocify.co')
42+
);
43+
}
44+
}

0 commit comments

Comments
 (0)