GithubHelp home page GithubHelp logo

jeffersonsimaogoncalves / password-changed-notification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from laratipsofficial/password-changed-notification

1.0 0.0 0.0 18 KB

License: MIT License

PHP 97.48% Blade 2.52%

password-changed-notification's Introduction

Password Changed Notification

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 asdh/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 PasswordChangedNotificationTrait trait and implement PasswordChangedNotificationContract interface

use Asdh\PasswordChangedNotification\Contracts\PasswordChangedNotificationContract;
use Asdh\PasswordChangedNotification\Traits\PasswordChangedNotificationTrait;

class User extends Authenticatable implements PasswordChangedNotificationContract
{
    use PasswordChangedNotificationTrait;
}

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';
}

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 passwordChangedNotificationMail(): Mailable
{
    return new YourOwnPasswordChangedNotificationMail;
}

Testing

composer test

Credits

License

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

password-changed-notification's People

Contributors

laratipsofficial avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.