Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
546 stars 65 forks source link

Tables Never Actually Load (infinite Loading state) #133

Closed dmmceldowney closed 1 year ago

dmmceldowney commented 1 year ago

After following the instructions for creating a UserTable based on the included documentation in a fresh project, my table does not load. I have changed nothing in the vendor folder (outside of some dd()'s that have been removed) and I have not published any of the vendor folder for modifications.

I was using my base App\Models\User::class for the data source.

When trying to nail down the issue, it seems like the Livewire table (Okipa\Livewire\Table.php) has a function called init() that is never getting hit. Because that function never gets called, the loader for the table is infinitely spinning. We dropped some dd()'s in this file and the init() function is never accessed.

I've tried this on Laravel 9.48.0 and 10.x, both provide the same result: infinite spinning and no loading. Here's the files I'm working with

<div>
    <livewire:table :config="App\Tables\UsersTable::class" />
</div>

// [namespace & includes...]

class UsersTable extends AbstractTableConfiguration
{
    protected function table(): Table
    {
        return Table::make()->model(User::class);
    }

    protected function columns(): array
    {
        return [
            Column::make('id')->sortable(),
            Column::make('created_at')
                ->sortable(),
            Column::make('updated_at')
                ->sortable()
                ->sortByDefault('desc'),
        ];
    }
}
ghost commented 1 year ago

Hi @dmmceldowney, are you sure that Livewire is correctly installed and functional?

Did you try to make the documentation example component work and everything is going fine?

dmmceldowney commented 1 year ago

Yes, livewire is correctly installed. I can create vanilla livewire components and they are reactive; I can browse to them and they populate with data. We've got alpine.js installed via CDN.

We've discovered if we manually update the $initialized value to true, the content loads but actions are not available.

raetron commented 1 year ago

I'm also having this issue. I'm using Bootstrap 5 and Livewire seems to be working on other files but it doesn't seem to load the Table.php in the Livewire file in the vendor directory. Is this file supposed to be called by something?

Happy to help debug as this looks like a great package. Running in dev mode via artisan serve. Package.json "devDependencies": { "@popperjs/core": "^2.11.6", "@vitejs/plugin-vue": "^4.0.0", "axios": "^0.21", "bootstrap": "^5.2.3", "jquery": "^3.2", "laravel-mix": "^6.0.6", "livewire-sortable": "^0.2.2", "lodash": "^4.17.19", "popper.js": "^1.12", "postcss": "^8.1.14", "resolve-url-loader": "^5.0.0", "sass": "^1.56.1", "sass-loader": "^11.0.1", "vue": "^3.2.36", "vue-loader": "^17.0.1", "webpack-cli": "^4.6.0" }, "dependencies": { "livewire": "^0.6.1" }

composer.json "require": { "php": "^8.2", "guzzlehttp/guzzle": "^7.0.1", "illuminate/contracts": "^10.9", "laravel/framework": "^10.0", "laravel/tinker": "^2.5", "laravel/ui": "^4.0", "livewire/livewire": "^2.12", "okipa/laravel-table": "^5.0", "orchestra/parser": "^8.0", "spatie/laravel-permission": "^5.10" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.5", "spatie/laravel-ignition": "^2.0", "fakerphp/faker": "^1.9.1", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.2", "nunomaduro/collision": "^6.1", "phpunit/phpunit": "^9.3.3"

raetron commented 1 year ago

Here is a screenshot showing the Livewire debugbar output: image

raetron commented 1 year ago

@dmmceldowney I figured out my issue - I had to add @livewireScripts to the app.blade.php file:

<body>
    @livewireScripts
dmmceldowney commented 1 year ago

@raetron D'OH. Same. Thank you for your time and assistance @ArthurLORENT !

Okipa commented 1 year ago

Nice, sorry for my lack of availability to bring support these last weeks, I've just started a new work and I've been quite busy!