Headlines for Grouped Activities
Introduction
A customer places an order, changes it, and places it again. The feed groups the placements, and a headline such as "placed 3 orders" tells the owner there are three orders when there is one. The owner needs the count of what happened, in words that don't overstate it.
An order can be placed more than once. A headline that calls every placement an order overstates how many orders there are. Keep the events, and choose wording that counts what actually happened.
Counting Repeated Activities
Suppose a customer places an order, then places it again after an amendment. Keep both occurrences so the feed can explain what happened. These are two place activities about one order:
| What Is Counted | Value |
|---|---|
placement activities (count) | 2 |
distinct orders (distinct.objects) | 1 |
:count counts activities. It cannot turn the two placements into a distinct order count. In this case, “placed 2 orders” would be wrong.
For names recorded in data rather than roles, see Naming Group Members From Activity Data.
Wording the Group Headline
Both placements share an actor, verb, object, target and context. Give this action a 45-minute quiet gap so the amendment joins the same object group. Name the shared order and count how many times it was placed. For a repeat group across orders, call the events “order placements”:
use App\Models\Order;
use Storyfeed\Facades\Story;
use Storyfeed\Grouping\GroupBuilder;
Story::for(Order::class)->verb('place')
->headline(':actor placed :object with :target')
->bursts(within: '45 minutes')
->grouped(
fn (GroupBuilder $group): GroupBuilder => $group
->object(':actor placed :object :count times')
->repeat(':actor made :count order placements with :target'),
);The same two activities now have a headline that describes their group:
For the declaration table, type and verb scope, and allowed tokens, see Defining Group Headlines.
Keeping Individual Content Visible
A group headline describes the events together; it does not replace their individual content. Quotes, images and other bodies remain on the member activities. To show every placement as its own row, retrieve the order's placements in log mode:
use App\Models\Order;
use Illuminate\Support\Facades\Route;
use Storyfeed\Facades\Storyfeed;
Route::get('/orders/{order}/placements', function (Order $order) {
return Storyfeed::feed()
->involving($order)
->only(['place'])
->log()
->get();
});This query returns one item per placement. Each placement remains a separate row. Render each item's body beside its headline.