Files
generic_table_examples/app/Tables/TableWithBindedRoutes.php
2025-05-03 01:57:26 -04:00

36 lines
1.0 KiB
PHP

<?php
namespace App\Tables;
use App\Models\Product;
use Mmt\GenericTable\Attributes\MappedRoute;
use Mmt\GenericTable\Components\Column;
use Mmt\GenericTable\Components\ColumnCollection;
use Mmt\GenericTable\Interfaces\IDragDropReordering;
use Mmt\GenericTable\Interfaces\IGenericTable;
use Mmt\GenericTable\Support\GenericTableSettings;
class TableWithBindedRoutes implements IGenericTable, IDragDropReordering
{
public GenericTableSettings $tableSettings;
public string $orderingColumn;
public function __construct()
{
$columns = ColumnCollection::make(
new Column('Id'),
new Column('Name'),
new Column('Description')
->bindToRoute(MappedRoute::make('with_relationships', ['id' => ':id'])),
new Column('Price'),
new Column('Stock'),
new Column('SubDepartment', 'subDepartment.name'),
new Column('Order')->hide()
);
$this->tableSettings = new GenericTableSettings(
Product::class, $columns
);
}
}