refactor(datatable): menjadikan dinamis kolom pengatur sorting
This commit is contained in:
parent
58e2c04116
commit
fac455e7f1
@ -3,6 +3,7 @@
|
||||
namespace App\Livewire\Datatable\Studio\Manage;
|
||||
|
||||
use App\Models\Purchase;
|
||||
use App\Traits\Datatable\WithAppendColumn;
|
||||
use App\Traits\Datatable\WithConfiguration;
|
||||
use App\Traits\Datatable\WithPrependColumn;
|
||||
use App\Traits\WithMediaHandler;
|
||||
@ -13,10 +14,14 @@
|
||||
|
||||
class PurchasesTable extends DataTableComponent
|
||||
{
|
||||
use WithConfiguration, WithMediaHandler, WithPrependColumn;
|
||||
use WithAppendColumn, WithConfiguration, WithMediaHandler, WithPrependColumn;
|
||||
|
||||
protected $model = Purchase::class;
|
||||
|
||||
protected string $sortColumn = 'purchase_date';
|
||||
|
||||
protected string $sortDirection = 'desc';
|
||||
|
||||
public function columns(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@ -33,11 +33,15 @@ public function configure(): void
|
||||
|
||||
// Sorting
|
||||
->setSortingPillsDisabled()
|
||||
->setSingleSortingEnabled()
|
||||
->setDefaultSort('created_at', 'desc')
|
||||
->setSingleSortingEnabled();
|
||||
|
||||
// Filter
|
||||
->setFilterPillsDisabled()
|
||||
$defaultColumn = property_exists($this, 'sortColumn') ? $this->sortColumn : 'created_at';
|
||||
$defaultDirection = property_exists($this, 'sortDirection') ? $this->sortDirection : 'desc';
|
||||
|
||||
$this->setDefaultSort($defaultColumn, $defaultDirection);
|
||||
|
||||
// Filter
|
||||
$this->setFilterPillsDisabled()
|
||||
->setFilterPopoverAttributes(
|
||||
[
|
||||
'class' => 'w-50',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user