Cześć uzywał ktos notyfikacji w Laravel? potrzebuje wyswietlić na kanale slack komunikaty z aplikacji. Tyle że ta dokumentacja https://laravel.com/docs/7.x/notifications#slack-notifications ze strony Laravel jest nie jasna albo coś porąbałem całkiem.
zainstalowałem paczkę composer require laravel/slack-notification-channel potem na slacku wygenerowalem sobie swoj key do kanału. env. skonfigurowalem tak jak w dokumentacji czyli wkleiłem klucz.
potem wygenerowalem sobie moja notyfikacje php artisan make:notification mojaNotyfikacja mój plik poniżej. I pytanie jak mam to teraz wywołać? żeby mi poszły te powiadomienia? Cos trzeba jeszcze podpiąć? jakas komenda z konsoli?
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
use App\Repositories\GeneratorLogsRepository;
class GeneratorLogsCompleted extends Notification {
use Queueable;
/**
* @var array
*/
private $account;
private $type;
/**
* Create a new notification instance.
*
* @param array $sets
* @param array $variant
* @param $account
*/
public function __construct($account, $type)
{
$this->account = $account;
$this->type = $type;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['slack'];
}
/**
* @param $notifiable
* @return SlackMessage
*/
public function toSlack($notifiable)
{
$percentageDiff = (new GeneratorLogsRepository)->notifyIfRequire($this->account, $this->type);
return (new SlackMessage)
//
->to('#fuckups')
->content('Uwaga dla konta :'.$this->account.' wygenerowano o: '.$percentageDiff.'% '.($percentageDiff > 0 ? 'więcej' : 'mniej' ) .'% ');
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}