Closed indovsky closed 7 months ago
Hi @indovsky,
I could not replicate your issue.
I have just created two PowerGrid components with Eloquent and one Collection data source, both using Tailwind.
app/Livewire/YourTable.php
)?Hi @indovsky,
I could not replicate your issue.
I have just created two PowerGrid components with Eloquent and one Collection data source, both using Tailwind.
- Are you using the default theme, or have you created your own theme?
- Could you please share your component's code (e.g.,
app/Livewire/YourTable.php
)?
Problem solved by updating laravel and livewire to newest version. My bad 😅
I am facing this same issue - when upgrading from 4.x to 5.x. The issue is mainly the $theme
appears to be an array as can be seen with the dd:
Upgrading Livewire and Laravel didn't solve it for me.
This is probably not table specific as it is happening on all tables. Any suggestions?
Update: The issue may be in the following code:
// src/PowerGridComponent.php
private function getTheme(): array
{
$class = $this->template() ?? powerGridTheme();
return Cache::rememberForever('powerGridTheme_' . $class, function () use ($class) {
/** @var ThemeBase $themeBase */
$themeBase = PowerGrid::theme($class);
return convertObjectsToArray((array) $themeBase->apply());
});
}
which returns an array to the renderView method
// src/PowerGridComponent.php
private function renderView(mixed $data): Application|Factory|View
{
$theme = $this->getTheme();
return view($theme['layout']['table'], [
'data' => $data,
'theme' => $this->getTheme(),
'table' => 'livewire-powergrid::components.table',
]);
}
I am facing this same issue - when upgrading from 4.x to 5.x. The issue is mainly the
$theme
appears to be an array as can be seen with the dd:Upgrading Livewire and Laravel didn't solve it for me.
This is probably not table specific as it is happening on all tables. Any suggestions?
Hi, after updating Laravel and Livewire, remove Powergrid from Composer. If you published Powergrid views, be sure to delete them and then reinstall Powergrid
Hello @akulmehta, did @indovsky suggestion work?
@luanfreitasdev no it didn't unfortunately. I updated everything and tried clearing all caches and views. I even tried installing PowerGrid v. 5.3.3 or 5.3.5 and even that didn't work.
I am wondering if this occurrs only on legacy tables which are upgraded from 3.x to 4.x to 5.x.
I believe you should completely remove published views (resources/views/vendor/...) and clear the cache on a refresh (optimize:clear).
@akulmehta Please create a new issue if the solutions provided here (and in the documentation) do not help.
It's not comfortable for other users to receive updates on an issue that it was already solved.
I know I shouldn't comment here but I solved my issue and didn't want to create a separate issue so I will post my solution here. For some reason publishing the views were not overwriting the previously published views I had. I manually deleted the resources/views/vendor/livewire-powergrid
folder and published the views again and it worked. Thank you for your help.
Thank you @akulmehta
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?
PHP Version
8.2
PowerGrid
5.3
Laravel
10.42
Livewire
3.3
Alpine JS
3.4.2
Theme
Tailwind 3.x with tailwind/forms
Describe the bug.
Fresh instance of laravel with powergrid. After creating a table and view with a table component I get an error "Attempt to read property "layout" on array". After publishing powergrid views and @dd($theme->layout) in /resources/views/vendor/livewire-powergrid/components/frameworks/tailwind/table-base.blade.php i can see $theme->layout returning array instead object.
Have I done something wrong or is this a bug?
To Reproduce...
Fresh installation
Extra information
No response