From 69a87b3a5cd035156e7f42d184be8f8593c69d6e Mon Sep 17 00:00:00 2001 From: David <75149259+TitanDvd@users.noreply.github.com> Date: Wed, 26 Mar 2025 06:11:38 -0400 Subject: [PATCH] #FEAT + Added EMPTY flag to be used by column settings --- app/Livewire/Examples/FrameComponent.php | 2 -- app/Tables/TableWithActionColumn.php | 2 +- app/Tables/Traits/WithColumnFormatter.php | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Livewire/Examples/FrameComponent.php b/app/Livewire/Examples/FrameComponent.php index 808ce90..5de3d61 100644 --- a/app/Livewire/Examples/FrameComponent.php +++ b/app/Livewire/Examples/FrameComponent.php @@ -7,8 +7,6 @@ use Livewire\Component; class FrameComponent extends Component { - - public function render() { return view('livewire.examples.frame-component') diff --git a/app/Tables/TableWithActionColumn.php b/app/Tables/TableWithActionColumn.php index 168d12a..b8ef244 100644 --- a/app/Tables/TableWithActionColumn.php +++ b/app/Tables/TableWithActionColumn.php @@ -17,7 +17,7 @@ class TableWithActionColumn implements IGenericTable, IActionColumn, IEvent public Model|string $model = Product::class; - public int $actionColumnIndex = -1; + public int $actionColumnIndex = 0; public function actionView(Model $item): \Illuminate\View\View { diff --git a/app/Tables/Traits/WithColumnFormatter.php b/app/Tables/Traits/WithColumnFormatter.php index 8cfd3ef..574cc49 100644 --- a/app/Tables/Traits/WithColumnFormatter.php +++ b/app/Tables/Traits/WithColumnFormatter.php @@ -8,6 +8,7 @@ use Mmt\GenericTable\Attributes\CellFormatter; use Mmt\GenericTable\Attributes\MappedColumn; use Mmt\GenericTable\Components\Column; use Mmt\GenericTable\Components\ColumnCollection; +use Mmt\GenericTable\Enums\ColumnSettingFlags; trait WithColumnFormatter { @@ -25,9 +26,15 @@ trait WithColumnFormatter new Column('Price'), new Column('Stock'), new Column('SubDepartment', 'subDepartment.name'), + new Column('Empty Column')->withSettings(ColumnSettingFlags::EMPTY), + new Column('Empty Hook')->withSettings(ColumnSettingFlags::EMPTY)->hookFormatter(fn($rowModel) => $this->emptyCol($rowModel)), ); } + public function emptyCol($model) + { + return ''.$model->id.''; + } #[CellFormatter('price')] public function priceFormatter(Model $modelItem)