46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Tables;
|
|
|
|
use App\Models\Product;
|
|
use Mmt\GenericTable\Components\Column;
|
|
use Mmt\GenericTable\Components\ColumnCollection;
|
|
use Mmt\GenericTable\Enums\ColumnSettingFlags;
|
|
use Mmt\GenericTable\Interfaces\IColumnFilter;
|
|
use Mmt\GenericTable\Interfaces\IDragDropReordering;
|
|
use Mmt\GenericTable\Interfaces\IGenericTable;
|
|
use Mmt\GenericTable\Support\FilterCollection;
|
|
use Mmt\GenericTable\Support\GenericTableSettings;
|
|
use Mmt\GenericTable\Support\SingleFilter;
|
|
|
|
class TableWithDragDropOrdering implements IGenericTable, IDragDropReordering, IColumnFilter
|
|
{
|
|
public GenericTableSettings $tableSettings;
|
|
|
|
public string $orderingColumn = 'order';
|
|
|
|
public FilterCollection $filters;
|
|
|
|
public bool $useBuilder;
|
|
|
|
public function __construct()
|
|
{
|
|
$columns = ColumnCollection::make(
|
|
new Column('Id'),
|
|
new Column('Name'),
|
|
new Column('Description'),
|
|
new Column('Price'),
|
|
new Column('Stock'),
|
|
new Column('Order')->withSettings(ColumnSettingFlags::DEFAULT_SORT_DESC)
|
|
);
|
|
|
|
$this->tableSettings = new GenericTableSettings(Product::class, $columns);
|
|
|
|
$this->filters = new FilterCollection(
|
|
SingleFilter::make('name', [
|
|
'Yes' => 'yes',
|
|
'No' => 'No',
|
|
])
|
|
);
|
|
}
|
|
} |