From dc4699c429e6ac88cf1f119277187201ed90eea9 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Wed, 19 Apr 2023 17:16:36 +0200 Subject: [PATCH] up --- Models/NotifyTheme.php | 22 +++++++++++++-------- Notifications/Channels/EsendexChannel.php | 17 +++++++++------- Notifications/HtmlNotification.php | 2 +- Notifications/RowAttributeNotification.php | 23 +--------------------- Notifications/SmsNotification.php | 17 ++++++++++------ Services/NamirialService.php | 2 +- 6 files changed, 38 insertions(+), 45 deletions(-) diff --git a/Models/NotifyTheme.php b/Models/NotifyTheme.php index 12b7ee41..a70e71c3 100755 --- a/Models/NotifyTheme.php +++ b/Models/NotifyTheme.php @@ -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() @@ -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 */ @@ -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, ]; } } diff --git a/Notifications/Channels/EsendexChannel.php b/Notifications/Channels/EsendexChannel.php index 005470e2..f1f358c7 100755 --- a/Notifications/Channels/EsendexChannel.php +++ b/Notifications/Channels/EsendexChannel.php @@ -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); diff --git a/Notifications/HtmlNotification.php b/Notifications/HtmlNotification.php index cdd3a9f8..bb8386ee 100755 --- a/Notifications/HtmlNotification.php +++ b/Notifications/HtmlNotification.php @@ -60,7 +60,7 @@ public function toMail($notifiable) /** * Undocumented function. * - * @param mixed $notifiable + * @param object $notifiable * * @return SmsData */ diff --git a/Notifications/RowAttributeNotification.php b/Notifications/RowAttributeNotification.php index d5c5acb8..f784062d 100755 --- a/Notifications/RowAttributeNotification.php +++ b/Notifications/RowAttributeNotification.php @@ -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 @@ -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) diff --git a/Notifications/SmsNotification.php b/Notifications/SmsNotification.php index 4d65b7fa..9c6a0436 100755 --- a/Notifications/SmsNotification.php +++ b/Notifications/SmsNotification.php @@ -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; @@ -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; @@ -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'), @@ -59,7 +63,8 @@ public function toSms($notifiable) { * * @return array */ - public function toArray($notifiable) { + public function toArray($notifiable) + { dddx($notifiable); return [ diff --git a/Services/NamirialService.php b/Services/NamirialService.php index ac7534dc..a12925c2 100755 --- a/Services/NamirialService.php +++ b/Services/NamirialService.php @@ -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());