38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tables;
|
|
|
|
use App\Models\Product;
|
|
use App\Tables\Extensions\IconColumn;
|
|
use Mmt\GenericTable\Components\Column;
|
|
use Mmt\GenericTable\Components\ColumnCollection;
|
|
use Mmt\GenericTable\Interfaces\IGenericTable;
|
|
use Mmt\GenericTable\Interfaces\IRowData;
|
|
use Mmt\GenericTable\Support\GenericTableSettings;
|
|
|
|
class TableWithCustomColumn implements IGenericTable
|
|
{
|
|
public GenericTableSettings $tableSettings;
|
|
|
|
public function __construct()
|
|
{
|
|
$icons = require_once('Extensions/bootstrap_icons.php');
|
|
|
|
$columns = new ColumnCollection();
|
|
|
|
$columns->add(new Column('Id'));
|
|
$columns->add(new Column('Name'));
|
|
$columns->add(new Column('Description'));
|
|
$columns->add(new IconColumn()->setIconIf(function(IRowData $rowModel) use($icons) {
|
|
|
|
if($rowModel->get('status') == 'discontinued') {
|
|
return $icons['bag-check'] . ' text-success';
|
|
}
|
|
else {
|
|
return $icons['bag-x'] . ' text-danger';
|
|
}
|
|
}));
|
|
|
|
$this->tableSettings = new GenericTableSettings(new Product(), $columns);
|
|
}
|
|
} |