Skip to content

Commit dd11a92

Browse files
authored
Merge pull request #3 from dharple/master
Fix issues encountered during implementation
2 parents f1796cd + 77bad10 commit dd11a92

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This package will observe the created and updated event of the models (check the
3434
In Your Form Request or Inline Validation, All You Need To Do Is Instantiate The `NotFromPasswordHistory` class passing the current user as an argument
3535
``` php
3636
<?php
37-
use Infinitypaul\LaravelPasswordHistoryValidation\Models\PasswordHistoryRepo;
37+
use Infinitypaul\LaravelPasswordHistoryValidation\Rules\NotFromPasswordHistory;
3838

3939
$this->validate($request, [
4040
'password' => [

Diff for: src/LaravelPasswordHistoryValidationServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function boot()
1515
{
1616
if ($this->app->runningInConsole()) {
1717
$this->publishes([
18-
__DIR__.'/../config/passwordHistory.php' => config_path('password-history-validation.php'),
18+
__DIR__.'/../config/passwordHistory.php' => config_path('password-history.php'),
1919
], 'password-config');
2020
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
2121

Diff for: src/Traits/PasswordHistoryTrait.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ public function passwordHistory()
1717

1818
public function deletePasswordHistory()
1919
{
20+
$keep = config('password-history.keep');
21+
$ids = $this->passwordHistory()
22+
->pluck('id')
23+
->sort()
24+
->reverse();
25+
26+
if ($ids->count() < $keep) {
27+
return;
28+
}
29+
30+
$delete = $ids->splice($keep);
31+
2032
$this->passwordHistory()
21-
->where('id', '<=', $this->passwordHistory()->first()->id - config('password-history.keep'))
33+
->whereIn('id', $delete)
2234
->delete();
2335
}
2436
}

0 commit comments

Comments
 (0)