ryangjchandler/laravel-make-user

Quickly create `User` models with Artisan.

v0.2.0 2022-02-08 22:11 UTC

This package is auto-updated.

Last update: 2024-04-09 03:13:40 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require ryangjchandler/laravel-make-user

Usage

You can create a User by running the artisan make:user command:

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:

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:

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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