Skip to content

Commit

Permalink
Merge pull request #28 from taylornetwork/2.4.0-wip
Browse files Browse the repository at this point in the history
v2.4.0
  • Loading branch information
itssamtaylor authored Nov 11, 2020
2 parents cb569e0 + d0ab4fd commit f939d7f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Easily generate unique usernames for a Laravel User Model

## Changes

**v2.4**

- This is a minor change but if you're using older versions of Laravel you may need to update your config file.
- Changed default User model from `App\User` to `App\Models\User` to mirror new Laravel versions (8.0+).
- Moved the adjective and noun word lists from the config file to a separate file, making the published config smaller and allowing you to create your own word lists if you wish.

**v2.3**

- Added support for random dictionary based usernames if a name is not provided. See the [generate](#generatename) method
Expand Down Expand Up @@ -86,6 +92,16 @@ class User extends Authenticatable
}
```

### Laravel 7 and below

If you're using Laravel 7 or below you'll need to publish the config using

```bash
$ php artisan vendor:publish --provider="TaylorNetwork\UsernameGenerator\ServiceProvider"
```

And update your `config/username_generator.php` file to match your User model namespace (`App\User`).

### Use username to login

To use the username to login instead of the email you need to add the following to your `LoginController`
Expand Down
19 changes: 19 additions & 0 deletions src/Support/LoadsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function loadConfig()
}

$this->configLoaded = true;
$this->checkForDictionary();
}

/**
Expand Down Expand Up @@ -151,4 +152,22 @@ public function withConfig(array $config): self

return $this;
}

/**
* Adds the the default dictionary words to the config if not set.
*/
private function checkForDictionary()
{
if ($this->configLoaded) {
$dictionary = include __DIR__.'/../config/dictionary.php';

if (empty($this->config->dictionary['adjectives'])) {
$this->config['dictionary']['adjectives'] = $dictionary['adjectives'];
}

if (empty($this->config->dictionary['nouns'])) {
$this->config['dictionary']['nouns'] = $dictionary['nouns'];
}
}
}
}
7 changes: 7 additions & 0 deletions src/config/dictionary.php

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/config/username_generator.php

Large diffs are not rendered by default.

0 comments on commit f939d7f

Please sign in to comment.