Examples updated

This commit is contained in:
David
2025-04-02 04:54:28 -04:00
parent 63779f8bad
commit 585c32d0cd
4 changed files with 24 additions and 6 deletions

View File

@@ -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;
}
}