hotrush / laravel-log-notification-channel
为Laravel提供日志通知通道
0.4.0
2022-05-05 16:46 UTC
Requires
- php: >=5.5.9
- illuminate/notifications: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- mockery/mockery: ^0.9.5
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-17 14:18:59 UTC
README
使用Laravel将通知发送到日志中,更容易模拟其他服务,例如短信或推送通知。
内容
安装
composer require hotrush/laravel-log-notification-channel
设置日志服务
您可以将 LOG_NOTIFICATIONS_CHANNEL
添加到您的 .env
文件中来自定义要使用的日志通道,否则将使用默认通道。
用法
<?php namespace App\Notifications; use App\Post; use Illuminate\Notifications\Notification; use NotificationChannels\Log\LogChannel; use NotificationChannels\Twilio\TwilioChannel; use NotificationChannels\Log\LogMessage; class AuthCodeCreatedNotification extends Notification { /** * @var Post */ private $post; /** * Create a new notification instance. * * @param Post $post * @return void */ public function __construct(Post $post) { $this->post = $post; } /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return app()->environment('production') ? [TwilioChannel::class] : [LogChannel::class]; } /** * Get the log message representation of the notification. * * @param mixed $notifiable * @return LogMessage */ public function toLog($notifiable) { return new LogMessage('Pretended sms send to :number and with content: :content'); } }
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。