›
byrcsc/laravel-mentions · 1.x
Connect mentions in Eloquent text to the users, teams, or other models they name.
A mention starts as text. When a comment contains @jane, your database does
not know which User row that handle means. It cannot find Jane's comments or
put the comment in her work queue from the text alone.
You need that link in cases such as these:
@jane to confirm an airport pickup.@sam to review a pricing change.@billing to check a refund.With Laravel Mentions configured, you can save a comment and query the user it names:
use App\Models\Comment;
use App\Models\User;
$jane = User::query()->where('name', 'jane')->firstOrFail();
$comment = Comment::query()->create([
'body' => 'Thanks @jane, can you review this?',
]);
$comment->mentioned();
$jane->mentionedIn()->get();
Comment::query()->whereMentions($jane)->get();The first call returns the models named by the comment. The second returns the mention records that point to Jane. The final query returns comments that mention her.
Laravel Mentions creates this link when you save the comment. It reads the configured text, finds the matching Eloquent model, and stores a relationship between the comment and the user.
The package handles four parts of a mention relationship:
The source and target can use integer, UUID, or ULID keys. Both sides are polymorphic, so comments and tasks can mention users and teams through the same table.
| Requirement | Supported versions |
|---|---|
| PHP | 8.3, 8.4 |
| Laravel | 12.x, 13.x |
| Database | MySQL, PostgreSQL, SQLite |
The package test suite runs the persistence and resolver behavior against all three databases.
Use the package events as the boundary for notifications. Keep authorization, rendering, and target cleanup in your application.