定制 brhn/password-changed-notification 二次开发

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

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

brhn/password-changed-notification

最新稳定版本:1.0.1

Composer 安装命令:

composer require brhn/password-changed-notification

包简介

A simple package to send mail notification to the user when the password is changed.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A simple package to send mail notification to the user when their password is changed.

Installation

You can install the package via composer:

composer require brhn/password-changed-notification

Usage

After installing the package, you can go to your User model or any other model that has password and email fields and use PasswordChangedTrait trait and implement PasswordChangedNotificationContract interface

use Brhn\PasswordChangedNotification\Contracts\PasswordChangedNotificationContract;
use Brhn\PasswordChangedNotification\Traits\PasswordChangedTrait;

class User extends Authenticatable implements PasswordChangedNotificationContract
{
    use PasswordChangedTrait;
}

Now whenever you change the password of the user, a mail will be automatically sent to that user. Isn't that easy.

By default the package will assume the columns name to be email and password. But if you have different column name for those fields then you can modify those as well.

Let's say you have the email column as user_email in your User model or any other model, then you can add emailColumnName method on the User model and return user_email from here like so:

public function emailColumnName(): string
{
    return 'user_email';
}

You can also modify the password column by adding this method.

public function passwordColumnName(): string
{
    return 'user_password';
}

You can also modify the name column by adding this method.

public function nameColumnName(): string
{
    return 'user_name';
}

You can also modify the name column by adding this method. This will be used in the mail like Hi Adam.

public function nameColumnName(): string
{
    return 'full_name';
}

Further, if you want to modify the mail that is being sent to the user, you can publish the mail view using

php artisan vendor:publish --tag="password-changed-notification-views"

The views view will now be published in resources/views/vendor/password-changed-notification/emails/password-changed-notification.blade.php. You can modify this file as per your need and when mail is sent to the user, it will be used.

You can also create your own mailable (the one that you create using php artisan make:mail command) and use that instead. For that you need to return the mailable that you have created by adding passwordChangedNotificationMail method on the User model and returning the mailable.

public function passwordChangedNotification(): Mailable
{
    return new YourOwnPasswordChangedNotificationMail($this);
}

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-19