1. Go to this page and download the library: Download byrcsc/laravel-mentions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
byrcsc / laravel-mentions example snippets
use Byrcsc\Mentions\Concerns\HasMentions;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
use HasMentions;
/** @var list<string> */
protected array $mentionableAttributes = ['body'];
}
use Byrcsc\Mentions\Concerns\Mentionable;
class User extends Authenticatable
{
use Mentionable;
}
$comment = Comment::create([
'body' => 'Thanks @jane, can you take a look?',
]);
$comment->mentioned(); // Mentioned models
$comment->mentions(); // Underlying mention records
$jane->mentionedIn(); // Records that mention Jane
use Byrcsc\Mentions\Events\MentionCreated;
Event::listen(function (MentionCreated $event) {
// $event->mention is the new mention record.
});