Added an example with two tables in the same parent component

This commit is contained in:
David
2025-03-31 01:19:15 -04:00
parent 69a87b3a5c
commit 63779f8bad
6 changed files with 89 additions and 5 deletions

View File

@@ -5,16 +5,36 @@ namespace App\Tables;
use App\Models\Product;
use App\Tables\Traits\WithColumnFormatter;
use Illuminate\Database\Eloquent\Model;
use Mmt\GenericTable\Components\Column;
use Mmt\GenericTable\Components\ColumnCollection;
use Mmt\GenericTable\Enums\ColumnSettingFlags;
use Mmt\GenericTable\Interfaces\IDragDropReordering;
use Mmt\GenericTable\Interfaces\IGenericTable;
use Mmt\GenericTable\Interfaces\ISingleSelectionFilter;
use Mmt\GenericTable\Support\SelectionFilterSettings;
class TableWithDragDropOrdering implements IGenericTable, IDragDropReordering
class TableWithDragDropOrdering implements IGenericTable, IDragDropReordering, ISingleSelectionFilter
{
use WithColumnFormatter;
public string $Order;
public Model|string $model = Product::class;
public ColumnCollection $columns;
public string $orderingColumn = 'order';
public SelectionFilterSettings $singleSelectionFilterSettings;
public function __construct()
{
$this->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->singleSelectionFilterSettings = new SelectionFilterSettings('name');
$this->singleSelectionFilterSettings->add('Make pop', 'ml');
}
}