Okipa / laravel-table

Generate tables from Eloquent models.
MIT License
532 stars 64 forks source link

closure must be an instance of App\Tables\Builder, instance of Illuminate\Database\Eloquent\Builder given #60

Closed oterminramiro closed 3 years ago

oterminramiro commented 3 years ago

Hi i am building a simple crud in laravel 8 and this is what happens when i try to do a query like the ones in the docs:

Argument 1 passed to App\Tables\UsersTable::App\Tables{closure}() must be an instance of App\Tables\Builder, instance of Illuminate\Database\Eloquent\Builder given, called in /var/www/html/vendor/okipa/laravel-table/src/Traits/Table/HasAdditionalQueries.php on line 25

It works by removing Builder from this:

->query(function (Builder $query) {
        $query->where('category_id', 1);
 })
Okipa commented 3 years ago

Hi @oterminramiro,

You're supposed to add use Illuminate\Database\Eloquent\Builder; in your imports to make this work, as you can see it in the doc example here: https://github.com/Okipa/laravel-table#advanced-configuration-example.