diff --git a/app/Livewire/Examples/WithTwoTablesComponent.php b/app/Livewire/Examples/WithTwoTablesComponent.php new file mode 100644 index 0000000..5e38ee9 --- /dev/null +++ b/app/Livewire/Examples/WithTwoTablesComponent.php @@ -0,0 +1,20 @@ + TableWithDragDropOrdering::class, + 'departments' => DepartmentTable::class + ]) + ->extends('components.layouts.app') + ->section('content'); + } +} diff --git a/app/Tables/DepartmentTable.php b/app/Tables/DepartmentTable.php new file mode 100644 index 0000000..8cfd5ab --- /dev/null +++ b/app/Tables/DepartmentTable.php @@ -0,0 +1,30 @@ +columns = new ColumnCollection(); + $this->columns->add(new Column("Id")); + $this->columns->add(new Column("Name")); + $this->columns->add(new Column("Tags")); + $this->columns->add(new Column("Status")); + $this->columns->add(new Column("Order")->sortable()->defaultSortDesc()); + } +} \ No newline at end of file diff --git a/app/Tables/TableWithDragDropOrdering.php b/app/Tables/TableWithDragDropOrdering.php index 26d31f6..a101ea4 100644 --- a/app/Tables/TableWithDragDropOrdering.php +++ b/app/Tables/TableWithDragDropOrdering.php @@ -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'); + } } \ No newline at end of file diff --git a/resources/views/livewire/examples/frame-component.blade.php b/resources/views/livewire/examples/frame-component.blade.php index 8f929be..57b1210 100644 --- a/resources/views/livewire/examples/frame-component.blade.php +++ b/resources/views/livewire/examples/frame-component.blade.php @@ -16,6 +16,7 @@