Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
marco76tv authored and Malebestia committed Sep 4, 2023
1 parent 050b285 commit dc4699c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 45 deletions.
22 changes: 14 additions & 8 deletions Models/NotifyTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public function linkable(): MorphTo
* @property int|null $post_id
* @property string $body_html
* @property string|null $theme
*
* @method static \Modules\Notify\Database\Factories\NotifyThemeFactory factory(...$parameters)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme newQuery()
Expand All @@ -173,19 +174,23 @@ public function linkable(): MorphTo
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereUpdatedBy($value)
*
* @property string|null $from_email
* @property string|null $logo_src
* @property int|null $logo_width
* @property int|null $logo_height
* @property-read array $logo
* @property int|null $logo_width
* @property int|null $logo_height
* @property array $logo
*
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereFromEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereLogoHeight($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereLogoSrc($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereLogoWidth($value)
* @method static \Illuminate\Database\Eloquent\Builder|NotifyTheme whereTheme($value)
*
* @mixin \Eloquent
*/
class NotifyTheme extends BaseModel {
class NotifyTheme extends BaseModel
{
/**
* @var array<string>
*/
Expand Down Expand Up @@ -262,11 +267,12 @@ class NotifyTheme extends BaseModel {
'logo',
];

public function getLogoAttribute(?array $value): array {
public function getLogoAttribute(?array $value): array
{
return [
'path' => asset($this->logo_src),
'width' => $this->logo_width,
'height' => $this->logo_height,
'path' => asset(strval($this->logo_src)),
'width' => $this->logo_width ?? 50,
'height' => $this->logo_height ?? 50,
];
}
}
Expand Down
17 changes: 10 additions & 7 deletions Notifications/Channels/EsendexChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@

namespace Modules\Notify\Notifications\Channels;

//use Illuminate\Support\Facades\Notification;
// use Illuminate\Support\Facades\Notification;
use Illuminate\Notifications\Notification;
use Modules\Notify\Actions\EsendexSendAction;
use Modules\Notify\Notifications\SmsNotification;
use Illuminate\Notifications\Notification;
use Modules\Xot\Contracts\ModelContactContract;

class EsendexChannel {
public function __construct() {
class EsendexChannel
{
public function __construct()
{
}

//public function send($notifiable, SmsNotification $notification) {
public function send(object $notifiable, Notification $notification): void {
// public function send($notifiable, SmsNotification $notification) {
public function send(object $notifiable, Notification $notification): void
{
// Send notification to the $notifiable instance...
// Call to an undefined method Illuminate\Notifications\Notification::toSms().
$message = $notification->toSms($notifiable);
// Send notification to the $notifiable instance...
$data = app(EsendexSendAction::class)->execute($message);
Expand Down
2 changes: 1 addition & 1 deletion Notifications/HtmlNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function toMail($notifiable)
/**
* Undocumented function.
*
* @param mixed $notifiable
* @param object $notifiable
*
* @return SmsData
*/
Expand Down
23 changes: 1 addition & 22 deletions Notifications/RowAttributeNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Modules\Notify\Datas\SmsData;
use Modules\Notify\Datas\EmailData;
use Modules\Xot\Contracts\ModelContactContract;

class RowAttributeNotification extends Notification
Expand Down Expand Up @@ -47,28 +46,8 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{

// Access to an undefined property Modules\Xot\Contracts\ModelContactContract::$notifyThemes.
$theme = $this->row->notifyThemes->first()->theme ?? 'ark';
// dddx($theme);
// dddx([
// 'row' => $this->row,
// 'from_email' => $this->row->mail_from,
// 'from' => $this->row->mail_from_email,
// 'subject' => $this->row->mail_subject,
// 'row email' => $this->row->email,
// 'body' => $this->row->mail_body,
// // 'body_html' => $this->row->
// ]);


// $email_data = EmailData::from([
// 'from' =>$this->row->mail_from_email,
// 'from_email' => $this->row->mail_from,
// 'subject' => $this->row->mail_subject,
// 'body_html' => $theme->body_html,
// 'body' => $this->row->mail_body,
// ]);
// dddx($email_data);

$message = (new MailMessage())
->from($this->row->mail_from_email, $this->row->mail_from)
Expand Down
17 changes: 11 additions & 6 deletions Notifications/SmsNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
use Illuminate\Notifications\Notification;
use Modules\Notify\Datas\SmsData;

class SmsNotification extends Notification implements ShouldQueue {
class SmsNotification extends Notification implements ShouldQueue
{
use Queueable;
public string $subject;
public string $html;
Expand All @@ -20,7 +21,8 @@ class SmsNotification extends Notification implements ShouldQueue {
*
* @return void
*/
public function __construct(string $from, string $subject, string $html) {
public function __construct(string $from, string $subject, string $html)
{
$this->from = $from;
$this->subject = $subject;
$this->html = $html;
Expand All @@ -33,18 +35,20 @@ public function __construct(string $from, string $subject, string $html) {
*
* @return array
*/
public function via($notifiable) {
public function via($notifiable)
{
return ['esendex'];
}

/**
* Undocumented function.
*
* @param mixed $notifiable
* @param object $notifiable
*
* @return SmsData
*/
public function toSms($notifiable) {
public function toSms($notifiable)
{
return SmsData::from([
'from' => $this->from,
'to' => $notifiable->routeNotificationFor('sms'),
Expand All @@ -59,7 +63,8 @@ public function toSms($notifiable) {
*
* @return array
*/
public function toArray($notifiable) {
public function toArray($notifiable)
{
dddx($notifiable);

return [
Expand Down
2 changes: 1 addition & 1 deletion Services/NamirialService.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private function uploadRequest(): self
return $this;
}

private function download(?string $filename = 'test.pdf'): self
private function download(string $filename = 'test.pdf'): self
{
$response = Http::withHeaders($this->headers)->{$this->http_method}($this->endpoint, $this->params);
$contents = strval($response->getBody()->getContents());
Expand Down

0 comments on commit dc4699c

Please sign in to comment.