---
title: "Blade directive — Likes for Laravel | Roundly"
description: "The @liked conditional renders the right heart state for the current or an explicit actor and reaction type."
url: https://roundly-consulting.com/open-source/docs/likes-for-laravel/blade-directive
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)

# Blade directive

The @liked conditional renders the right like-button state without glue code:

```blade
@liked($post)
    <x-icon name="heart-filled" />
@else
    <x-icon name="heart" />
@endliked
```

- @liked($model) — uses the resolved actor.
- @liked($model, $actor) — honours an explicit actor.
- @liked($model, $actor, 'love') — honours a reaction type; without one, default\_reaction is checked.

## Guest-visible pages

Without an explicit actor — or with a null one — the directive resolves one like every read (actor\_resolver, else auth()->user()). A guest gets the @else branch, never an exception, so it is safe on pages guests can see:

```blade
{{-- a guest gets the @else branch, never an exception --}}
@liked($post)
    <button>Unlike</button>
@else
    <button>Like</button>
@endliked

{{-- or pass an actor you already hold --}}
@liked($post, $team, 'love')
    <span>Your team loves this</span>
@endliked
```

The directive is only registered if your app doesn’t already define a @liked directive. For feeds, prefer withLikedState() — it hydrates the same state for every row in one query.

## 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)
