rappasoft / laravel-livewire-tables

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

does not like if you have another table component installed #4

Closed rabol closed 4 years ago

rabol commented 4 years ago

Just as a comparison i have also kdion4891/laravel-livewire-tables in my test project

even if I create a new page only with your component the page will not render

Steps:

composer require rappasoft/laravel-livewire-tables
composer require kdion4891/laravel-livewire-tables
// This makes the kdion4891 component
php artisan make:table UserTable -Model=User
// This makes your component
php artisan livewire:make RUserTable

Then I have this code for your component

<?php

namespace App\Http\Livewire;

use App\User;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\TableComponent;
use Rappasoft\LaravelLivewireTables\Views\Link;

class RUserTable extends TableComponent
{
    public function query() : Builder
    {
        return User::query();
    }

    public function columns() : array
    {
        return [
            Column::make('ID')
                ->searchable()
                ->sortable(),
            Column::make('Name')
                ->searchable()
                ->sortable(),
            Column::make('E-mail', 'email')
                ->searchable()
                ->sortable(),
            Column::make('Actions')
                ->addComponent(Link::make('Edit'))
                ->addComponent(Link::make('Delete'))
        ];
    }
}

I have a /users route in my HomeController

the blade file looks like this:

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <livewire:r-user-table></livewire:r-user-table>
    </div>
</div>
@endsection

When loading the page I get the following error:

Undefined variable: header_view (View: /home/vagrant/code/test/vendor/kdion4891/laravel-livewire-tables/resources/views/table.blade.php) (View: /home/vagrant/code/test/vendor/kdion4891/laravel-livewire-tables/resources/views/table.blade.php)

I have tried

php artisan cache:clear
php artisan view:clear
composer dumpautoload

same result

I would normally not have both, but...

rappasoft commented 4 years ago

I'm assuming because we have the same package name and view name so maybe Laravel does not know which to use? Either way I doubt someone would be using both?

rappasoft commented 4 years ago

@rabol if you pull in that bug fix it will fix the conflict.

rappasoft commented 4 years ago

@rabol did you get a chance to retest?

rabol commented 4 years ago

Yes, I have tested and it works fine

A few small notes:

one needs to install font awesome - not in default Laravel 7 it would be beneficial if all samples are working samples

rappasoft commented 4 years ago

good idea