Files
generic_table_examples/app/Tables/TableWithBulkActions.php

56 lines
2.0 KiB
PHP

<?php
namespace App\Tables;
use App\Models\Product;
use Mmt\GenericTable\Components\Column;
use Mmt\GenericTable\Components\ColumnCollection;
use Mmt\GenericTable\Interfaces\IBulkAction;
use Mmt\GenericTable\Interfaces\IGenericTable;
use Mmt\GenericTable\Support\BulkAction;
use Mmt\GenericTable\Support\BulkActionCollection;
use Mmt\GenericTable\Support\BulkActionGroup;
use Mmt\GenericTable\Support\BulkActionSettings;
use Mmt\GenericTable\Support\GenericTableSettings;
class TableWithBulkActions implements IGenericTable, IBulkAction
{
public GenericTableSettings $tableSettings;
public BulkActionCollection $bulkActionCollection;
public function __construct()
{
$columns = ColumnCollection::make(
new Column('Id'),
new Column('Description'),
new Column('Price'),
new Column('Stock'),
new Column('Department', 'subDepartment.department.name'),
new Column('SubDepartment', 'subDepartment.name'),
);
$this->bulkActionCollection = BulkActionCollection::make(
BulkActionGroup::make('Emails',
BulkActionGroup::make('FxLive',
BulkActionGroup::make('Marketing',
BulkAction::make('100:1 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
BulkAction::make('100:2 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
BulkAction::make('100:3 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
),
BulkAction::make('100:3 Boost Fund', fn($e) => $this->ProcessMassiveEmailMarketing($e)),
)
)
);
$this->tableSettings = new GenericTableSettings(Product::class, $columns);
}
public function ProcessMassiveEmailMarketing(BulkActionSettings $bulkActionSettings)
{
dd('Processing action ... ', $bulkActionSettings);
}
}