-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add TransactionSuccessNotification for succe
- Loading branch information
1 parent
94957c7
commit bda6df5
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
|
||
class TransactionSuccessNotification extends Notification implements ShouldQueue | ||
{ | ||
use Queueable; | ||
|
||
protected $transactionDetails; | ||
|
||
public function __construct(array $transactionDetails) | ||
{ | ||
$this->transactionDetails = $transactionDetails; | ||
} | ||
|
||
public function via($notifiable) | ||
{ | ||
return ['mail']; | ||
} | ||
|
||
public function toMail($notifiable) | ||
{ | ||
return (new MailMessage) | ||
->subject('Transaction Successful') | ||
->greeting('Hello!') | ||
->line('Your transaction has been successfully processed.') | ||
->line('Transaction ID: ' . $this->transactionDetails['transaction_id']) | ||
->line('Amount: $' . number_format($this->transactionDetails['amount'], 2)) | ||
->action('View Transaction', url('/transactions/' . $this->transactionDetails['transaction_id'])) | ||
->line('Thank you for using our application!'); | ||
} | ||
|
||
public function toArray($notifiable) | ||
{ | ||
return [ | ||
'transaction_id' => $this->transactionDetails['transaction_id'], | ||
'amount' => $this->transactionDetails['amount'], | ||
]; | ||
} | ||
} |