https://github.com/ryangjchandler/laravel-make-user
Quickly create `User` models with Artisan. ⚡️
https://github.com/ryangjchandler/laravel-make-user
Last synced: 4 months ago
JSON representation
Quickly create `User` models with Artisan. ⚡️
- Host: GitHub
- URL: https://github.com/ryangjchandler/laravel-make-user
- Owner: ryangjchandler
- License: mit
- Archived: true
- Created: 2021-08-04T08:00:26.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-08T22:11:43.000Z (over 3 years ago)
- Last Synced: 2025-03-15T20:48:44.631Z (4 months ago)
- Language: PHP
- Size: 19.5 KB
- Stars: 14
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Quickly create `User` models with Artisan.
[](https://packagist.org/packages/ryangjchandler/laravel-make-user)
[](https://github.com/ryangjchandler/laravel-make-user/actions?query=workflow%3Arun-tests+branch%3Amain)
[](https://github.com/ryangjchandler/laravel-make-user/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
[](https://packagist.org/packages/ryangjchandler/laravel-make-user)## Installation
You can install the package via composer:
```bash
composer require ryangjchandler/laravel-make-user
```## Usage
You can create a `User` by running the `artisan make:user` command:
```bash
php artisan make:user
```By default, it will ask for the `name`, `email` and `password` for the `User`.
### Changing the model
This command will use the `App\Models\User` model. If this model doesn't exist, you can change it using the `MakeUser::model` method:
```php
public function boot()
{
MakeUser::model(\App\User::class);
}
```### Asking extra questions
If you wish to ask for more information from the user, you can register an extension using the `MakeUser::extend` method:
```php
public function boot()
{
MakeUser::extend(function (MakeUserCommand $command, array $fields) {
$username = $command->ask('Username');return array_merge([
'username' => $username,
], $fields);
});
}
```This will ask the command runner for a `username` and then add it to the `$fields` that are passed to the model's `create` method.
## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Ryan Chandler](https://github.com/ryangjchandler)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.