z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.14k stars 2.81k forks source link

LogicException when creating admin admin:create-user #5634

Closed theiconnz closed 2 years ago

theiconnz commented 2 years ago

Description:

Try to create a new admin user but generate LogicException error

Steps To Reproduce:

php artisan admin:create-user

First three questions worked Please enter a username to login: Please enter a password to login: Please enter a name to display:

Once I entered the display name and press enter. It generate an error.


 LogicException 

  Choice question must have at least 1 choice available.

  at vendor/symfony/console/Question/ChoiceQuestion.php:36
     32▕      */
     33▕     public function __construct(string $question, array $choices, mixed $default = null)
     34▕     {
     35▕         if (!$choices) {
  ➜  36▕             throw new \LogicException('Choice question must have at least 1 choice available.');
     37▕         }
     38▕ 
     39▕         parent::__construct($question, $default);
     40▕ 

      +15 vendor frames 
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
theiconnz commented 2 years ago

Will update this ticket of my own, if someone have same issue.

Issue is related to roles. Create a new role and then run the admin:create-user command.

My original issue was since I have run migrate:refresh default user was not working. so I tried to create admin user. But admin roles were also refreshed so it generated the error

You can find more information Encore\Admin\Console\CreateUserCommand.php

Another option is to run php artisan admin:install