NovinkaZverejnili sme 50+ Laravel balíkov ako open source
Custom AI apps, agents and automation — Roundly ConsultingRoundly
Všetky balíky

Nové správy môžete voliteľne premeniť na Laravel notifikácie. Po zapnutí každá odoslaná správa notifikuje ostatných notifikovateľných účastníkov vlákna — odosielateľ notifikáciu nikdy nedostane a účastníci bez traitu Notifiable sa preskočia:

MESSAGES_NOTIFICATIONS=true
// config/messages.php
'notifications' => [
    'enabled' => env('MESSAGES_NOTIFICATIONS', false),
    'notification' => RoundlyConsulting\Messages\Notifications\NewMessageNotification::class,
    'channels' => ['database'],   // mail is never forced
],

Predvolená notifikácia

RoundlyConsulting\Messages\Notifications\NewMessageNotification beží vo fronte (ShouldQueue), doručuje cez notifications.channels a implementuje toArray() s údajmi:

  • message_id a thread_id,
  • preview — skrátený náhľad správy podľa jej typu,
  • sender_id a sender_type.

toMail() neimplementuje, takže na e-mail potrebujete vlastnú triedu.

Prispôsobenie

Ak chcete upraviť kanály a obsah, publikujte upraviteľnú kópiu predvolenej notifikácie a nasmerujte na ňu konfiguráciu — kópia žije v mennom priestore vašej aplikácie a spočiatku sa správa presne ako notifikácia balíka:

php artisan vendor:publish --tag="messages-notifications"
# → app/Notifications/Messages/NewMessageNotification.php (App\Notifications\Messages)
// config/messages.php
'notifications' => [
    'notification' => App\Notifications\Messages\NewMessageNotification::class,
],

Prípadne nasmerujte notifications.notification na úplne vlastnú triedu — v konštruktore dostane odoslanú Message, takže funguje aj rozšírenie predvolenej:

use RoundlyConsulting\Messages\Notifications\NewMessageNotification;

class ChatMessageReceived extends NewMessageNotification
{
    // $this->message is the sent Message — override via() or toArray(), or add toMail()
}

// config/messages.php
'notification' => App\Notifications\ChatMessageReceived::class,

Prejavte lásku k open source

Tento balík je zadarmo pod licenciou MIT. Ak vám šetrí čas, jednorazový príspevok alebo členstvo na Patreone nám pomôže ho ďalej udržiavať, testovať a dokumentovať.

Ďalšie spôsoby podpory vrátane kryptomien

Odoslaním daru súhlasíte s našimi podmienkami prijímania darov.

Chcete to zabudovať do svojho produktu?

Naše balíky integrujeme do zákazkových Laravel a AI riešení. Napíšte nám, na čom pracujete, a ozveme sa do 48 hodín.