Feature/phone register (#11)
Co-authored-by: ISMAIL MASSERAN <topaz@ISMAILs-Macbook.local> Co-authored-by: ISMAIL MASSERAN <topaz@Mac.dlinkrouter.local> Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Feedback\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Modules\Feedback\Entities\Feedback;
|
||||
use Modules\Auth\Entities\User;
|
||||
|
||||
class FeedbackNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $feedback;
|
||||
protected $sender;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(Feedback $feedback, User $sender = null)
|
||||
{
|
||||
$this->feedback = $feedback;
|
||||
$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 [
|
||||
'feedback_id' => $this->feedback->id,
|
||||
'sender_id' => $this->sender ? $this->sender->id : null,
|
||||
'type' => 'feedback_submitted',
|
||||
'message' => $this->getNotificationMessage(),
|
||||
'feedback_title' => $this->feedback->title ?? 'Unknown',
|
||||
'feedback_type' => $this->feedback->type ?? 'Unknown',
|
||||
'feedback_priority' => $this->feedback->priority ?? 'normal',
|
||||
'user_name' => $this->feedback->user ? $this->feedback->user->name : 'Anonymous',
|
||||
'user_email' => $this->feedback->user ? $this->feedback->user->email : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notification message
|
||||
*/
|
||||
private function getNotificationMessage(): string
|
||||
{
|
||||
$userName = $this->feedback->user ? $this->feedback->user->name : 'Pengguna tanpa nama';
|
||||
$feedbackTitle = $this->feedback->title ?? 'Unknown';
|
||||
$feedbackType = $this->feedback->type ?? 'Unknown';
|
||||
$feedbackPriority = $this->feedback->priority ?? 'normal';
|
||||
$feedbackId = $this->feedback->id;
|
||||
|
||||
return "Maklum balas baru telah diterima. ID: {$feedbackId}, Tajuk: {$feedbackTitle}, Jenis: {$feedbackType}, Keutamaan: {$feedbackPriority}, Pengguna: {$userName}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user