Examples updated
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user