diff --git a/app/Tables/TableWithBindedRoutes.php b/app/Tables/TableWithBindedRoutes.php index ea37c20..09a77fe 100644 --- a/app/Tables/TableWithBindedRoutes.php +++ b/app/Tables/TableWithBindedRoutes.php @@ -6,12 +6,15 @@ use App\Tables\Traits\WithColumnFormatter; 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; -class TableWithBindedRoutes implements IGenericTable +class TableWithBindedRoutes implements IGenericTable, IDragDropReordering { use WithColumnFormatter; + public string $orderingColumn; + public function __construct() { $this->columns = ColumnCollection::make( diff --git a/app/Tables/TableWithExport.php b/app/Tables/TableWithExport.php index 92ee870..445c6b0 100644 --- a/app/Tables/TableWithExport.php +++ b/app/Tables/TableWithExport.php @@ -6,6 +6,7 @@ use App\Models\Product; use App\Tables\Traits\WithExportableProductColumns; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Response; +use Mmt\GenericTable\Attributes\CellFormatter; use Mmt\GenericTable\Components\ColumnCollection; use Mmt\GenericTable\Interfaces\IExportable; use Mmt\GenericTable\Interfaces\IGenericTable; @@ -19,7 +20,15 @@ class TableWithExport implements IGenericTable, IExportable public function onExport(ExportEventArgs $args) : BinaryFileResponse|Response { + $args->query->take(5); + $args->settings->useFormatters = true; $args->settings->fileName = 'products'; return $args->export(); } + + #[CellFormatter('price')] + public function priceFormatter($rowModel) + { + return '$'.$rowModel->price; + } } \ No newline at end of file diff --git a/app/Tables/TableWithFilters.php b/app/Tables/TableWithFilters.php index 10d56f0..ce14d27 100644 --- a/app/Tables/TableWithFilters.php +++ b/app/Tables/TableWithFilters.php @@ -5,6 +5,7 @@ namespace App\Tables; use App\Models\Product; use Illuminate\Database\Eloquent\Model; +use Mmt\GenericTable\Components\Column; use Mmt\GenericTable\Components\ColumnCollection; use Mmt\GenericTable\Enums\CommonDateFilter; use Mmt\GenericTable\Interfaces\IDateRangeFilter; @@ -31,8 +32,6 @@ class TableWithFilters implements IGenericTable, IEvent, IDateRangeFilter, ISing public SelectionFilterSettings $multiSelectionFilterSettings; - public bool $isTableLoaderEnabled = true; - public string $orderingColumn = 'order'; @@ -42,6 +41,13 @@ class TableWithFilters implements IGenericTable, IEvent, IDateRangeFilter, ISing CommonDateFilter::LAST_2_MONTHS, CommonDateFilter::LAST_3_MONTHS ); + + $this->columns = ColumnCollection::make( + new Column('Id')->hookFormatter(fn($row) => '#'.$row->id), + new Column('Order')->sortable()->defaultSort(), + new Column('Name'), + new Column('Price') + ); $this->singleSelectionFilterSettings = new SelectionFilterSettings('status') ->add('Out of stock', 'out_of_stock') @@ -68,8 +74,8 @@ class TableWithFilters implements IGenericTable, IEvent, IDateRangeFilter, ISing - public function tableLoadingIndicatorView(): \Illuminate\View\View + public function tableLoadingIndicatorView(string $id): \Illuminate\View\View { - return view('custom-loader'); + return view('custom-loader', ['genericId' => $id]); } } \ No newline at end of file diff --git a/resources/views/custom-loader.blade.php b/resources/views/custom-loader.blade.php index 65e9c57..eefd3e1 100644 --- a/resources/views/custom-loader.blade.php +++ b/resources/views/custom-loader.blade.php @@ -1,4 +1,4 @@ -