-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Malebestia
committed
Sep 4, 2023
1 parent
599ba82
commit 1617734
Showing
4 changed files
with
193 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
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,13 @@ | ||
<?php | ||
|
||
namespace Modules\Notify\Data; | ||
|
||
use Spatie\LaravelData\Data; | ||
|
||
class SmsData extends Data { | ||
|
||
public string $from; | ||
public string $to; | ||
public string $body; | ||
|
||
} |
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
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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Modules\Notify\Notifications; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Modules\Notify\Data\SmsData; | ||
|
||
class RowAttributeNotification extends Notification { | ||
use Queueable; | ||
public Model $model; | ||
/** | ||
* Create a new notification instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Model $row) { | ||
$this->row=$row; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* | ||
* @return array | ||
*/ | ||
public function via($notifiable) { | ||
/* | ||
dddx(['via'=>$this->row->getNotifyVia(),'notifiable'=>$notifiable,'row'=>$this->row]); | ||
return ['mail']; | ||
*/ | ||
return $this->row->getNotifyVia(); | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) { | ||
dddx($notifiable); | ||
/* | ||
return (new MailMessage()) | ||
->subject($this->subject) | ||
->line('---') | ||
->view('notify::notifications.html', ['html' => $this->html]); | ||
*/ | ||
} | ||
|
||
/** | ||
* Undocumented function | ||
* | ||
* @param mixed $notifiable | ||
* @return SmsData | ||
*/ | ||
public function toSms($notifiable) { | ||
return SmsData::from([ | ||
'from' => $this->row->sms_from, | ||
'to'=> $this->row->mobile_phone, | ||
'body'=>$this->row->sms_body, | ||
]); | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* | ||
* @return array | ||
*/ | ||
public function toArray($notifiable) { | ||
dddx($notifiable); | ||
|
||
return [ | ||
]; | ||
} | ||
} |