first init
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Modules\Auth\Entities\User;
|
||||
|
||||
class UserActivationNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $newUser;
|
||||
protected $sender;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(User $newUser, User $sender = null)
|
||||
{
|
||||
$this->newUser = $newUser;
|
||||
$this->sender = $sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*/
|
||||
public function via($notifiable): array
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*/
|
||||
public function toArray($notifiable): array
|
||||
{
|
||||
return [
|
||||
'user_id' => $this->newUser->id,
|
||||
'sender_id' => $this->sender ? $this->sender->id : null,
|
||||
'type' => 'user_activation_required',
|
||||
'message' => $this->getNotificationMessage(),
|
||||
'user_name' => $this->newUser->name ?? 'Unknown',
|
||||
'user_email' => $this->newUser->email ?? 'Unknown',
|
||||
'user_army_number' => $this->newUser->army_number ?? 'Unknown',
|
||||
'user_unit_name' => $this->newUser->unit->name ?? 'Unknown',
|
||||
'user_status' => $this->newUser->status ?? 'pending',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification message
|
||||
*/
|
||||
private function getNotificationMessage(): string
|
||||
{
|
||||
$userName = $this->newUser->name ?? 'Unknown';
|
||||
$userEmail = $this->newUser->email ?? 'Unknown';
|
||||
$userArmyNumber = $this->newUser->army_number ?? 'Unknown';
|
||||
$unitName = $this->newUser->unit->name ?? 'Unknown';
|
||||
|
||||
return "Pengguna baru memerlukan pengaktifan. Nama: {$userName}, Email: {$userEmail}, No. Tentera: {$userArmyNumber}, Unit: {$unitName}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user