Blade directive
The @liked conditional renders the right like-button state without glue code:
@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:
{{-- 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>
@endlikedThe 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 cryptoBy donating, you agree to our donation terms.
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.