Courses

Filament 3 From Scratch: Practical Course

Table Actions: Row / Bulk / Header

Summary of this lesson:
- Creating custom table actions
- Implementing bulk actions
- Adding header actions
- Managing action groups

In the process of while we're building simple tables, you got already familiar with three types of actions:

  • Edit/Delete buttons in a column
  • Create a button on top
  • Multi-checkbox Bulk Actions on top-left

In this lesson, we will look at how to create custom actions for all those cases and more.


Edit/Delete + Extra Buttons

Let's try to add another button to the Orders table, like "Mark as Complete," which would require confirmation and would change the status of the order.

Migration:

Schema::table('orders', function (Blueprint $table) {
$table->boolean('is_completed')->default(false);
});

Also, we make it fillable:

app/Models/Order.php:

class Order extends Model
{
use HasFactory;
 
protected $fillable = [
'user_id',
'product_id',
'price',
'is_completed',
];

Now, here's what action we can add to the table:

app/Filament/Resources/OrderResource.php:

return $table
->columns([
// ...
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('Mark Completed')
->requiresConfirmation()
->icon('heroicon-o-check-badge')
->hidden(fn (Order $record) => $record->is_completed)
->action(fn (Order $record) => $record->update(['is_completed' => true])),
])

Here's the visual result:

Pretty sure that the code above is self-explanatory, but here are...

The full lesson is only for Premium Members.
Want to access all 24 lessons of this course? (101 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord