Text Version of the Lesson
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...
So, How to HIDE the default "New order" button on the top-right corner?
I get it!Comment out the line of method "getHeaderActions" in file ListOrders.php.
Yes, I cover that in the later lesson :)
How to position the New order button, from headerActions, to the left? I did exactly like in the tutorial but i get it on the right.