---
title: "Reaction breakdown — Likes for Laravel | Roundly"
description: "Likes::for()->summary() returns totals, per-type counts, the top reaction and the viewer’s own reaction for reaction bars."
url: https://roundly-consulting.com/open-source/docs/likes-for-laravel/reaction-summary
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Likes for Laravel](https://roundly-consulting.com/open-source/docs/likes-for-laravel.md)

# Reaction breakdown

Likes::for($post)->summary() — or $post->reactionSummary() on the model — returns a ReactionSummary for reaction bars and counters: one grouped count query plus, at most, one lookup for the viewer’s reaction:

```php
$summary = Likes::for($post)->summary($viewer); // viewer optional; same as $post->reactionSummary()
$summary->total;            // int — sum of all reactions
$summary->counts;           // ['like' => 8, 'love' => 4]
$summary->countFor('love'); // int
$summary->has('love');      // bool
$summary->top;              // ?string — most-used type (config order breaks ties), null if none
$summary->viewerReaction;   // ?string — the viewer's active reaction (the first configured one if several), null without one
$summary->toArray();        // ['total' => .., 'counts' => [...], 'top' => .., 'viewer' => ..]
```

- counts maps each reaction type to its count, ordered by type on every database; countFor() returns 0 for a type nobody used.
- top is the most-used type; ties go to the type listed first in reactions. When no configured type is present any more, top is the most-used stored type, ties alphabetical. viewerReaction is the viewer’s active reaction — the first configured one if they left several.
- Pass a viewer, or let it default to the resolved actor. For guests viewerReaction is null — it never throws.

## A reaction bar in Blade

```blade
@php($summary = $post->reactionSummary())

@foreach ($summary->counts as $type => $count)
    <span @class(['font-semibold' => $summary->viewerReaction === $type])>
        {{ $type }} {{ $count }}
    </span>
@endforeach
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/likes-for-laravel.md)
