PHPackages                             luilliarcec/laravel-user-commands - 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. [CLI &amp; Console](/categories/cli)
4. /
5. luilliarcec/laravel-user-commands

ActiveLibrary[CLI &amp; Console](/categories/cli)

luilliarcec/laravel-user-commands
=================================

Laravel User Commands is a package that provides the necessary commands for user manipulation from the console.

3.1.1(4y ago)1317MITPHPPHP ^7.2|^8.0

Since Dec 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/luilliarcec/laravel-user-commands)[ Packagist](https://packagist.org/packages/luilliarcec/laravel-user-commands)[ Docs](https://github.com/luilliarcec/laravel-user-commands)[ RSS](/packages/luilliarcec-laravel-user-commands/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

Laravel User Commands V3
========================

[](#laravel-user-commands-v3)

[![run-tests](https://github.com/luilliarcec/laravel-user-commands/workflows/run-tests/badge.svg)](https://github.com/luilliarcec/laravel-user-commands/workflows/run-tests/badge.svg)[![Latest Version on Packagist](https://camo.githubusercontent.com/8eb20009a1f99104d5b80bf87507c75dbf2d3ad5c1384528e6b76ff3202de74b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c75696c6c6961726365632f6c61726176656c2d757365722d636f6d6d616e64732e737667)](https://packagist.org/packages/luilliarcec/laravel-user-commands)[![Quality Score](https://camo.githubusercontent.com/35090ea2e065150b71422dbd7e07e230423bcc4bb2cf9d5c5a3fd90c5e6e8043/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c75696c6c6961726365632f6c61726176656c2d757365722d636f6d6d616e6473)](https://scrutinizer-ci.com/g/luilliarcec/laravel-user-commands)[![Total Downloads](https://camo.githubusercontent.com/315dd21c342507ed5a57f3925c131dd8c53be2b52f6ac1eb147efa02bfe4bdb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c75696c6c6961726365632f6c61726176656c2d757365722d636f6d6d616e6473)](https://packagist.org/packages/luilliarcec/laravel-user-commands)[![GitHub license](https://camo.githubusercontent.com/15c1668f3f0056f3ad97534833058a721041f30fcdc8e49647c61aa8aee911f1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c75696c6c6961726365632f6c61726176656c2d757365722d636f6d6d616e6473)](https://github.com/luilliarcec/laravel-user-commands/blob/develop/LICENSE.md)

If like me, you have ever considered having commands to manipulate users within your application, this package will help you.

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

[](#installation)

You can install the package via composer:

```
composer require luilliarcec/laravel-user-commands
```

Now publish the configuration file into your app's config directory, by running the following command:

```
php artisan vendor:publish --provider="Luilliarcec\UserCommands\UserCommandsServiceProvider"
```

That is all. 😀

Usage
-----

[](#usage)

The package has 4 basic commands

CommandsDescriptionuser:createCreate a new user in your appuser:reset-passwordRestore a user's passworduser:deleteDelete a useruser:restoreRestore a user### Create Users

[](#create-users)

```
php artisan user:create
```

###### Fields

[](#fields)

All the fields defined in your fillable property of your model will be used when executing the command. If you want to add more fields you can do it from your config file (your file takes precedence over your model, so if you define the fields in your config file the fields of your fillable property will be ignored)

###### Rules

[](#rules)

Whether you have fields defined in your model or in the configuration file, the `filled` rule will be dynamically applied to those fields. If you want to add custom rules you can do it from the rules key from your configuration file, these will be merged in such a way that those fields that have not been given a custom rule will use the `filled` rule by default.

After all, you are free to extend the command and configure it to your liking.

```
php artisan user:create -a username:larcec -a "other_field:Value of field"
```

or

```
php artisan user:create --attributes=username:larcec --attributes="other_field:Value of field"
```

If you want to mark the user's email as verified you can pass the argument `--verified` Ex.:

```
php artisan user:create --verified
```

If your model uses roles and permissions, you must configure the model of the roles and permissions and the name of the relationships in the configuration file.

You can then pass the permissions or roles as arguments.

```
php artisan user:create -p "user-create" -p "user-edit"
```

It should be noted that the `roles` and `permissions`
must already exist in your database and will be searched by the `name` field

Once the user has been created, the `notification` that it has been created will be sent if it implements the `MustVerifyEmail` interface and if the `verification.verify` route name exists

If you want to apply your own logic or just save default data for all users, you can extend the command and apply your necessary logic, or copy the `prepareForSave` method and add your necessary data. Ex.:

```
