Actions

Actions

Actions refer to the CRUD actions used by the resources (index/create/show/edit).

A nice thing is that you can customize individual actions for individual resources. For example, you may want to use the default CRUD actions for showing the index, show, and edit screens of an OrderResource, but use a custom action for the "create order" action.

This is useful because schema-based CRUD screens only go so far: they can make your application feel like connected database rows — which it really is, but you want your users to feel like they're interacting with the actual business concepts that they deal with. Not database records.

So in this example, you'd create a CreateOrderAction (a Livewire component) and tell Lean to use it by specifying a customActions() method:

public static function customActions(): array
{
    return [
        'create' => CreateOrderResource::class,
    ];
}

You can see this example in more detail here: Create Order Action