PHPackages                             beliven-it/laravel-password-history - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. beliven-it/laravel-password-history

ActiveLibrary[Security](/categories/security)

beliven-it/laravel-password-history
===================================

A small package for implements a password history

1.2.0(1y ago)0251[3 PRs](https://github.com/beliven-it/laravel-password-history/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Nov 23Pushed 1mo agoCompare

[ Source](https://github.com/beliven-it/laravel-password-history)[ Packagist](https://packagist.org/packages/beliven-it/laravel-password-history)[ Docs](https://github.com/beliven-it/laravel-password-history)[ GitHub Sponsors](https://github.com/beliven-it)[ RSS](/packages/beliven-it-laravel-password-history/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (13)Versions (11)Used By (0)

Laravel Password History
========================

[](#laravel-password-history)

[![](./repo/banner.png)](./repo/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4394b9c2ba5a253d77e82d9d6855ac146e42291d2fe8aae810d565badeb709b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656c6976656e2d69742f6c61726176656c2d70617373776f72642d686973746f72792e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://packagist.org/packages/beliven-it/laravel-password-history)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bd4adb0d112d64efb3687a567a00141f77e6521cb7d1935718496f81ba7d4979/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656c6976656e2d69742f6c61726176656c2d70617373776f72642d686973746f72792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://github.com/beliven-it/laravel-password-history/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3081ac8bea94283003e382fbd46e04524053200220bb213a20f225a6b258fc89/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656c6976656e2d69742f6c61726176656c2d70617373776f72642d686973746f72792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://github.com/beliven-it/laravel-password-history/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/46d0b02983f7e8e9c259942a36b51e94093ade2bc76165db0ac49b6e1e549eb8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62656c6976656e2d69742f6c61726176656c2d70617373776f72642d686973746f72792e7376673f7374796c653d666f722d7468652d6261646765266c6162656c436f6c6f723d32613263326526636f6c6f723d306662636364)](https://packagist.org/packages/beliven-it/laravel-password-history)

This package allows you to keep track of the last passwords used by a user.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require beliven-it/laravel-password-history
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="password-history-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="password-history-config"
```

This is the contents of the published config file:

```
return [
    // Use -1 for unlimited history
    'depth' => (int) env('PASSWORD_HISTORY_DEPTH', 10),
];
```

The only value configurable is the depth of the password history. This value is the number of passwords that will be stored in the history. When a user tries to set a password that is in the history, the validation will fail.

Usage
-----

[](#usage)

The library allow to apply a trait in your own models.

Let's try to use in the `User` model:

```
