rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.79k stars 339 forks source link

[Bug]: Undefined variable $selectedVisibleColumns #2005

Closed SakoDev closed 2 weeks ago

SakoDev commented 3 weeks ago

What happened?

Everything was working well since I did a composer update, and then this error faced me: Undefined variable $selectedVisibleColumns

iss

How to reproduce the bug

No response

Package Version

3.4

PHP Version

8.2.x

Laravel Version

11.0

Alpine Version

3.13.5

Theme

Tailwind 3.x

Notes

use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; use App\Models\Banner; use Illuminate\Database\Eloquent\Builder; use Rappasoft\LaravelLivewireTables\Views\Columns\DateColumn; use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn;

class BannerTable extends DataTableComponent { protected $model = Banner::class;

public function configure(): void
{
    $this->setPrimaryKey('id');
    $this->setPaginationEnabled();
}

public function builder(): Builder
{
    return Banner::query()->select('id', 'title', 'description', 'text_button', 'image', 'created_at');
}

public function columns(): array
{
    return [
        Column::make("Id", "id")->sortable(),
        Column::make("Title", "title")->sortable()->collapseOnTablet(),
        Column::make("Description", "description")->sortable()->collapseOnTablet(),
        Column::make("Text button", "text_button")->sortable()->collapseOnTablet(),
        ImageColumn::make('Banner')
            ->location(fn ($row) => asset('storage/images/banners/' . $row->image))
            ->attributes(fn ($row) => ['class' => 'object-cover w-full h-full']),
        Column::make("Image", "image")->hideIf(true),
        DateColumn::make("Created at", "created_at")
            ->inputFormat('Y-m-d H:i:s')
            ->outputFormat('Y-m-d')
            ->emptyValue('Not Found')
            ->collapseOnTablet(),
        Column::make('Actions')
            ->label(function ($row) {
                return view('tables.cells.banner-actions', [
                    'row' => $row,
                    'model' => Banner::class,
                    'component' => 'banner',
                ])->render();
            })
            ->html(),
    ];
}

public function deleteItem($id)
{
    Banner::findOrFail($id)->delete();
    Notyf()->addSuccess('The banner has been deleted successfully');
}

}

Error Message

Undefined variable $selectedVisibleColumns

@foreach($selectedVisibleColumns as $index => $column)

@endforeach

lrljoe commented 2 weeks ago

Have you previously published the Views?

SakoDev commented 2 weeks ago

Yes,i have. The tables were working great tell i did a composer update > Have you previously published the Views?

SakoDev commented 2 weeks ago

I fixed the problem , i just downgraded the version from 3.4.22 to 3.4.2

lrljoe commented 2 weeks ago

Downgrading isn't really fixing it!

If you previously published the views, then try moving the published folder to see if the problem persists.