+ Added new example about the new feature: custom column
This commit is contained in:
David
2025-03-17 22:33:11 -04:00
parent 096c7944b9
commit 25c6b316bd
14 changed files with 2260 additions and 7 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace App\Tables\Extensions;
use Closure;
use Mmt\GenericTable\Attributes\MappedRoute;
use Mmt\GenericTable\Components\Column;
use Mmt\GenericTable\Enums\ColumnSettingFlags;
use Mmt\GenericTable\Interfaces\IColumn;
use Mmt\GenericTable\Interfaces\IColumnFormatter;
use Mmt\GenericTable\Interfaces\IColumnRenderer;
use Str;
class IconColumn implements IColumn, IColumnRenderer
{
public int $settings = 0;
public string $bindedRoute = '';
public ?MappedRoute $mappedRoute = null;
public ?string $databaseColumnName = 'status';
public string $columnTitle = 'Status';
private Closure $setIconCallback;
public function __construct()
{
if($this->databaseColumnName == null)
$this->databaseColumnName = Str::snake($this->columnTitle);
}
public function renderCell(\Illuminate\Database\Eloquent\Model $rowModel): string
{
$icon = $this->setIconCallback->call($this, $rowModel);
return <<<HTML
<div class = "w-100 d-flex justify-content-start">
<i class = "$icon me-2"></i>
</div>
HTML;
}
public function route(MappedRoute $route)
{
$this->mappedRoute = $route;
return $this;
}
public function setIconIf(Closure $callback)
{
$this->setIconCallback = $callback;
return $this;
}
}

File diff suppressed because it is too large Load Diff