kdion4891 / laravel-livewire-tables

A dynamic, responsive Laravel Livewire table component with searching, sorting, checkboxes, and pagination.
302 stars 41 forks source link

Don't works if model primaryKey is not `id` #32

Open PrestaSafe opened 4 years ago

PrestaSafe commented 4 years ago

I've a model, Customer

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    protected $table = 'customer';
    protected $primaryKey = 'id_customer';
}

and i've this error:

Capture d’écran 2020-09-01 à 19 52 15

If i change to key (in the database) to id it's working !

I'm issing something ?

Thanks

bobkosse commented 3 years ago

@PrestaSafe You can easy fix this by adding public $sort_attribute = 'id_customer'; to your table component.