Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.42k stars 209 forks source link

Getting error when trying to create table with Query Builder #1394

Closed akulmehta closed 5 months ago

akulmehta commented 5 months ago

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

Yes - I didn't work.

Is there an error in the console?

Yes

PHP Version

8.2.12

PowerGrid

5.3.7

Laravel

10.43.0

Livewire

3.4.4

Alpine JS

3.13.5

Theme

Bootstrap

Describe the bug.

I am migrating a legacy codebase from PowerGrid3.x to 4.x and now to 5.x.

I tried creating a table using the prompt:

php artisan powergrid:create

And I going through the prompts I get an error:

  Typed property PowerComponents\LivewirePowerGrid\Commands\CreateCommand::$dataBaseTableName must not be accessed before initialization

  at vendor\power-components\livewire-powergrid\src\Commands\CreateCommand.php:209

Below is the full copy pasted console output (check extra information).

To Reproduce...

First click on "FOO" then....

Extra information

$ php artisan powergrid:create
     __     ____                          ______     _     __
    / /_,  / __ \____ _      _____  _____/ ____/____(_)___/ /
    /_ ,' / /_/ / __ \ | /| / / _ \/ ___/ / __/ ___/ / __  / 
    /'   / ____/ /_/ / |/ |/ /  __/ /  / /_/ / /  / / /_/ /  
        /_/    \____/|__/|__/\___/_/   \____/_/  /_/\__,_/     

 livewire-powergrid.check_version is false

  What is the name of your Table Component? [UserTable]
❯ UserTable2

  What type of data source will you use? [Eloquent Builder]
  Eloquent Builder ............................................................................................................................... 0  
  Query Builder .................................................................................................................................. 1  
  Collection ..................................................................................................................................... 2  
❯ 1
1

  Create columns based on Model's fillable property? (yes/no) [yes]
❯ n

   Error 

  Typed property PowerComponents\LivewirePowerGrid\Commands\CreateCommand::$dataBaseTableName must not be accessed before initialization

  at vendor\power-components\livewire-powergrid\src\Commands\CreateCommand.php:209
    205▕             $this->stub = str_replace('{{ modelKebabCase }}', Str::kebab($this->modelName), $this->stub);
    206▕         }
    207▕
    208▕         if (strtolower($this->datasourceOption) === strtolower(self::DATASOURCE_QUERY_BUILDER)) {
  ➜ 209▕             $this->stub = str_replace('{{ databaseTableName }}', $this->dataBaseTableName, $this->stub);
    210▕         }
    211▕
    212▕         $livewirePath = str(strval(config('livewire.class_namespace')))
    213▕             ->replace('\\', '/')

  1   vendor\power-components\livewire-powergrid\src\Commands\CreateCommand.php:77
      PowerComponents\LivewirePowerGrid\Commands\CreateCommand::askModel()

  2   vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
      PowerComponents\LivewirePowerGrid\Commands\CreateCommand::handle()
dansysanalyst commented 5 months ago

I could reproduce the issue, and I am looking into it.

Thanks, @akulmehta

dansysanalyst commented 5 months ago

@akulmehta are you using PHP directly on Windows OS?

I noticed your setup process is falling back to Symphony Questions instead of Laravel Prompt.

303797241-52b2d52e-a8d0-4b74-b724-621d6c553da5

akulmehta commented 5 months ago

@dansysanalyst I am using a XAMPP installation - so yes, it is PHP directly on Windows.

luanfreitasdev commented 5 months ago

Released: https://github.com/Power-Components/livewire-powergrid/releases/tag/v5.3.8