Closed SPQRBrutus closed 3 years ago
Please post the code to your table and any other relevant information.
It's nothing special.
<?php
namespace App\Http\Livewire\Frontend\Client;
use App\Domains\Client\Models\Klient;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Filter;
class ClientsTable extends DataTableComponent
{
/**
* @return Builder
*/
public function query(): Builder
{
return Klient::select("klient_id", "knazov", "kmesto", "ktyp", "kobchodnik", "kschvalenie", "kico")
->where("zruseny", "<>", 1)
->when($this->getFilter('type'), fn ($query, $type) => $query->where('ktyp', $type))
->when($this->getFilter('owned'), function ($query, $owned) {
if ($owned == 1) {
$query->where("kobchodnik", "AdminIstrator");
} elseif ($owned == 2) {
$query->where(function ($query) {
$query->where("kobchodnik", "")->orWhere("kobchodnik", null);
});
}
});
}
public function filters(): array
{
return [
'type' => Filter::make('Type')
->select([
'' => 'Everything',
Klient::TYPE_AGENCY => 'Agency',
Klient::TYPE_CLIENT => 'Client',
]),
'owned' => Filter::make('Salesperson')
->select([
'' => 'Everything',
1 => 'Owned',
2 => 'Without Salesperson',
]),
];
}
/**
* @return array
*/
public function columns(): array
{
return [
Column::make(__('Title'), 'knazov')
->sortable()
->searchable(),
Column::make(__('City'), 'kmesto')
->searchable()
->sortable(),
Column::make(__('Status'), 'kschvalenie')
->sortable(),
Column::make(__('Type'), 'ktyp')
->sortable(),
Column::make(__('Salesperson'), 'kobchodnik')
->searchable()
->sortable(),
Column::make(__('Actions'))
->format(function ($value, $column, $row) {
return view('frontend.client.includes.actions', ['client' => $row]);
}),
Column::make(__('Links'))
->format(function ($value, $column, $row) {
return view('frontend.client.includes.links', ['client' => $row]);
}),
];
}
}
View:
@section('content')
<x-backend.card>
<x-slot name="body">
<livewire:frontend.client.clients-table />
</x-slot>
</x-backend.card>
@endsection
Laravel version: 8.24 Livewire version: 2.0 Datatables version: 1.10.4
Looks fine from here. Hard to say without the whole project. Feel free to e-mail me the project and I'll install and try to see if it's a bug or not.
Looks fine from here. Hard to say without the whole project. Feel free to e-mail me the project and I'll install and try to see if it's a bug or not.
Can't do this. It's basically raw installation of yours laravel boilerplate only with updated Livewire datatables and SQLAnywhere database module.
Found the problem. My database table had different primary key then ID. After change
public string $primaryKey = 'klient_id';
it's starts working.
Thanks for help
When I have 10 records and for example 3 after filtering only 3 rows are rendered and other 7 stay thare.