WIP email notification
This commit is contained in:
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Emails;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class SendVerifyEmail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->subject('Verify Email')
|
||||
->markdown('email_user');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
32
Modules/Internal/Events/ForgetPassword.php
Normal file
32
Modules/Internal/Events/ForgetPassword.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Events;
|
||||
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ForgetPassword
|
||||
{
|
||||
use SerializesModels;
|
||||
public $data;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should be broadcast on.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\Internal\Emails\SendVerifyEmail;
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
@@ -84,6 +87,9 @@ class AuthController extends Controller
|
||||
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||
}
|
||||
|
||||
|
||||
Mail::to($user->email)->send(new SendVerifyEmail($user));
|
||||
|
||||
return response()->json($user);
|
||||
}
|
||||
|
||||
|
||||
31
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
31
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Listeners;
|
||||
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class SendVerifyEmail
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param ForgetPassword $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(ForgetPassword $event)
|
||||
{
|
||||
dd($event->data);
|
||||
}
|
||||
}
|
||||
61
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
61
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class NotifyVerifyEmail extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', 'https://laravel.com')
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
35
Modules/Internal/Providers/EventServiceProvider.php
Normal file
35
Modules/Internal/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
use Modules\Internal\Listeners\SendVerifyEmail;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $listen = [
|
||||
ForgetPassword::class => [
|
||||
SendVerifyEmail::class,
|
||||
],
|
||||
];
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,11 @@ use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class InternalServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $listen = [
|
||||
ForgetPassword::class => [
|
||||
SendVerifyEmail::class,
|
||||
],
|
||||
];
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
@@ -51,7 +56,8 @@ class InternalServiceProvider extends ServiceProvider
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
module_path($this->moduleName, 'Config/config.php'),
|
||||
$this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Internal\\Providers\\InternalServiceProvider"
|
||||
"Modules\\Internal\\Providers\\InternalServiceProvider",
|
||||
"Modules\\Internal\\Providers\\EventServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
|
||||
Reference in New Issue
Block a user