定制 anourvalar/eloquent-notification 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anourvalar/eloquent-notification

最新稳定版本:1.5.14

Composer 安装命令:

composer require anourvalar/eloquent-notification

包简介

Laravel Notification - model layer

README 文档

README

Installation

Step #1: Install the package

composer require anourvalar/eloquent-notification

Step #2: Publish the resources

php artisan vendor:publish --provider=AnourValar\\EloquentNotification\\Providers\\AnourValarEloquentNotificationServiceProvider

Notification feature

Step #1: Add notification routes for User model

/**
 * Route notifications for the Telegram channel.
 *
 * @param  \Illuminate\Notifications\Notification  $notification
 * @return string|null
 */
public function routeNotificationForTelegram($notification)
{
    return $this->telegram_chatid; // set your attribute
}

/**
 * Route notifications for the SMS channel.
 *
 * @param  \Illuminate\Notifications\Notification  $notification
 * @return string|null
 */
public function routeNotificationForSms($notification)
{
    return $this->phone; // set your attribute
}

/**
 * Route notifications for the Push channel.
 *
 * @param  \Illuminate\Notifications\Notification  $notification
 * @return string|array|null
 */
public function routeNotificationForPush($notification)
{
    return $this->tokens()->orderBy('id', 'DESC')->limit(10)->pluck('push_token')->toArray(); // set your attribute
}

Step #2: Create a notification

namespace App\Notifications\Triggers;

use Illuminate\Notifications\Messages\MailMessage;

class NewPostNotification extends \AnourValar\EloquentNotification\AbstractNotification
{
    /**
     * Create a new notification instance.
     */
    public function __construct(public \App\Post $post)
    {
        parent::__construct();
    }

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->line($this->post->title)
            ->action('Notification Action', url('/'))
            ->line('Thank you for using our application!');
    }
}

Step #3: Collect (group) notify (optional)

App::make(Service::class)->collectNotify($user, EmailUpdatedNotification::class, []);

Confirm feature

Step #1: Add middleware to the HTTP Kernel

/**
 * The application's middleware aliases.
 *
 * Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
 *
 * @var array<string, class-string|string>
 */
protected $middlewareAliases = [
    // <...>
    'confirm.pow' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPow::class,
    'confirm.email.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmEmailInput::class,
    'confirm.email.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmEmailMy::class,
    'confirm.phone.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPhoneInput::class,
    'confirm.phone.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmPhoneMy::class,
    'confirm.totp.input' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmTotpInput::class,
    'confirm.totp.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmTotpMy::class,
    'confirm.fa.my' => \AnourValar\EloquentNotification\Http\Middleware\ConfirmFaMy::class,
];

Step #2: Explore the ConfirmService

统计信息

  • 总下载量: 111
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固