Allow overriding the php artisan nova:user command #5836
Answered
by
crynobone
connecteev
asked this question in
Q&A
-
Description:If you modify the One potential solution is to override this command by creating a file with the same name at app/Console/Commands/UserCommand.php: However, a more elegant solution would be to accept the additional fields ( |
Beta Was this translation helpful? Give feedback.
Answered by
crynobone
Aug 24, 2023
Replies: 1 comment 1 reply
-
|
You can add the following in use Illuminate\Console\Command;
use Laravel\Nova\Nova;
use Laravel\Nova\Util;
Nova::createUserUsing(
function (Command $command) {
return [
$command->ask('Name'),
$command->ask('Email Address'),
$command->secret('Password'),
$command->ask('Username', null),
];
},
function ($name, $email, $password, $username) {
$model = Util::userModel();
return tap((new $model())->forceFill([
'name' => $name,
'email' => $email,
'password' => Hash::make($password),
'username' => $username,
'profile_image_url' => 'https://static.generated.photos/vue-static/home/feed/male.png',
]))->save();
}
); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
connecteev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add the following in
App\Providers\NovaServiceProvider.