Table
You may need to show the current Workflow state of your models inside the Filament table definition.
State Table column
Let’s assume that you have a model
Project
that implementHasWorkflow
interface, and aProjectResource
that define the Filament resource for this model.
If you want to show Workflow states inside your resource table, you can use one of the following table columns:
State column
This column is based on Filment TextColumn
to show the current Workflow state of your model, and can be used as follows:
<?php
namespace App\Filament\Resources;
use App\Models\Project;use Devaslanca\Fluent\Tables\Columns\StateColumn;use Filament\Tables;use Filament\Tables\Table;
class ProjectResource extends Resource{ protected static ?string $model = Project::class;
// ...
public static function table(Table $table): Table { return $table ->columns([ // ...
StateColumn::init(),
// ... ]); }}
This column will render as the following:
State select column
You can also use the StateSelectColumn
to use a select column letting your users change the state of your model (always based on their Workflow permissions).
<?php
namespace App\Filament\Resources;
use App\Models\Project;use Devaslanca\Fluent\Tables\Columns\StateSelectColumn;use Filament\Tables;use Filament\Tables\Table;
class ProjectResource extends Resource{ protected static ?string $model = Project::class;
// ...
public static function table(Table $table): Table { return $table ->columns([ // ...
StateSelectColumn::init(),
// ... ]); }}
Both of these table columns are based on Filament table columns (
TextColumn
andSelectColumn
), so feel free to customize it as you like.