diff --git a/composer.json b/composer.json index 495c06d..6b0f2c8 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,8 @@ ], "require": { "php": "^7.0", - "illuminate/console": "^5.3.28", - "illuminate/events": "^5.3.28" + "illuminate/console": "^5.3.23", + "illuminate/support": "^5.3.23" }, "autoload": { "psr-4": { diff --git a/src/Commands/CreateUser.php b/src/Commands/CreateUser.php index 90d432b..c4bd4f3 100644 --- a/src/Commands/CreateUser.php +++ b/src/Commands/CreateUser.php @@ -2,7 +2,6 @@ namespace BOAIdeas\CreateUser\Commands; -use App\User; use Illuminate\Console\Command; class CreateUser extends Command @@ -32,11 +31,16 @@ public function handle() $email = $this->ask('User email'); $password = $this->ask('User password'); - User::create([ + $model = config('createuser.model'); + + $user = new $model; + + $model::fill([ 'name' => $name, 'email' => $email, 'password' => bcrypt($password), ]); + $this->info('New user created!'); } } diff --git a/src/Config/createuser.php b/src/Config/createuser.php new file mode 100644 index 0000000..983a602 --- /dev/null +++ b/src/Config/createuser.php @@ -0,0 +1,4 @@ + 'App\User' +]; \ No newline at end of file diff --git a/src/CreateUserServiceProvider.php b/src/CreateUserServiceProvider.php new file mode 100644 index 0000000..19473f3 --- /dev/null +++ b/src/CreateUserServiceProvider.php @@ -0,0 +1,31 @@ +publishes([ + __DIR__.'/Config/createuser.php' => config_path('createuser.php'), + ]); + } + + /** + * Register the application services. + * + * @return void + */ + public function register() + { + $this->mergeConfigFrom( + __DIR__.'/Config/createuser.php', 'createuser' + ); + + $this->commands([ + Commands\CreateUser::class, + ]); + } +} \ No newline at end of file