musahmusah / password-change-notification
A simple laravel package to send mail notification to the user when their password is changed.
Requires
- php: ^8.1
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-20 11:25:40 UTC
README
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 musahmusah/password-change-notification
You can publish and run the migrations with:
php artisan vendor:publish --tag="password-change-notification-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="password-change-notification-config"
This is the contents of the published config file:
return [ 'queue-notification-mail' => false, ];
Optionally, you can publish the views using
php artisan vendor:publish --tag="password-change-notification-views"
Usage
After installing the package, you can go to your User
model or any other model that has password and email fields and use ObservePasswordChangeMail
trait and implement PasswordChangedNotificationContract
interface
use MusahMusah\PasswordChangeNotification\Contracts\PasswordChangedNotificationContract; use MusahMusah\PasswordChangeNotification\Traits\ObservePasswordChangeMail; class User extends Authenticatable implements PasswordChangedNotificationContract { use ObservePasswordChangeMail; }
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. This will be used in the mail like Hi Adam
.
public function nameColumnName(): string { return 'full_name'; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.