›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-mentions
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Mention records
  • Parsing text
  • Resolving targets
  • Synchronization

Operations

  • Scan multiple attributes
  • Use markup mentions
  • Mention groups
  • Querying mentions
  • React to lifecycle events
  • Control synchronization
  • Extend the package

Reference

  • Configuration
  • Public API
  • Published assets
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Mention records
  • Parsing text
  • Resolving targets
  • Synchronization

Operations

  • Scan multiple attributes
  • Use markup mentions
  • Mention groups
  • Querying mentions
  • React to lifecycle events
  • Control synchronization
  • Extend the package

Reference

  • Configuration
  • Public API
  • Published assets
  • Testing
  • Troubleshooting

byrcsc/laravel-mentions · 1.x

Introduction.

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:

  • A booking note asks @jane to confirm an airport pickup.
  • A project comment asks @sam to review a pricing change.
  • A support note asks @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.

What the package provides

The package handles four parts of a mention relationship:

  1. A parser finds handles in plain text or target IDs in HTML attributes.
  2. Resolvers match those candidates to Eloquent models.
  3. Synchronization diffs the targets against stored mention records.
  4. Relationships, scopes, and events expose the result to your application.

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.

Supported versions

RequirementSupported versions
PHP8.3, 8.4
Laravel12.x, 13.x
DatabaseMySQL, PostgreSQL, SQLite

The package test suite runs the persistence and resolver behavior against all three databases.

What it does not do

  • It does not send notifications.
  • It does not render handles as links or sanitize HTML.
  • It does not provide routes, controllers, facades, or Artisan commands.
  • It does not decide whether a source may mention a target.
  • It does not provide an editor or autocomplete endpoint.
  • It does not remove mention rows when a target model is deleted.

Use the package events as the boundary for notifications. Keep authorization, rendering, and target cleanup in your application.

What to read next

  • Installation and setup to publish the table and configure the first target model.
  • Quick start to create and query one mention.
  • Mention records to understand what the package stores.
NextInstallation and setup
View source

On this page

  1. What the package provides
  2. Supported versions
  3. What it does not do
  4. What to read next