-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
17 changed files
with
211 additions
and
44 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
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
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
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,94 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Models\Polls\Poll; | ||
use Carbon\Carbon; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Notifications\Notification; | ||
use NotificationChannels\Telegram\TelegramMessage; | ||
|
||
class NewPollAvailableNotification extends Notification | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Create a new notification instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @return array<int, string> | ||
*/ | ||
public function via(object $notifiable): array | ||
{ | ||
return [ | ||
'telegram', | ||
]; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
*/ | ||
public function toMail(object $notifiable): MailMessage | ||
{ | ||
return (new MailMessage) | ||
->line('The introduction to the notification.') | ||
->action('Notification Action', url('/')) | ||
->line('Thank you for using our application!'); | ||
} | ||
|
||
public function toTelegram($notifiable): TelegramMessage | ||
{ | ||
$poll = Poll::first(); | ||
$url = route('filament.pr0p0ll.resources.public-polls.teilnehmen', [ | ||
'record' => $poll, | ||
]); | ||
|
||
$message = TelegramMessage::create() | ||
->to(config('services.telegram-bot-api.channel')) | ||
->line('*📊 Neue Umfrage verfügbar!*'."\n") | ||
->line("*Titel: {$poll->title}*\n") | ||
->when($poll->description, function (TelegramMessage $message) use ($poll) { | ||
$message->line('*Beschreibung:* '.$poll->description); | ||
}) | ||
->when($poll->category, function (TelegramMessage $message) use ($poll) { | ||
$message->line("*\nKategorie:* {$poll->category->title}"); | ||
}) | ||
->when($poll->not_anonymous, function (TelegramMessage $message) use ($poll) { | ||
$pr0UserName = $poll->user->name; | ||
$pr0grammUserProfileUrl = 'https://pr0gramm.com/'.$pr0UserName; | ||
$message->line("*\nBenutzer:* [$pr0UserName]($pr0grammUserProfileUrl)"); | ||
}) | ||
->line("*\nEndet in:* ".Carbon::make($poll->closes_after)?->diffForHumans()."\n") | ||
->line("*\nURL:* [$url]($url)") | ||
->button('Jetzt teilnehmen', $url); | ||
|
||
return $message; | ||
} | ||
|
||
public function toPr0gramm($notifiable): string | ||
{ | ||
return 'Hallo, es wurde eine neue Umfrage veröffentlicht. Jetzt teilnehmen.'; | ||
} | ||
|
||
/** | ||
* Get the array representation of the notification. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(object $notifiable): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.