❤️ This package helps you complete @ function
- PHP >= 5.4.0
$ composer require dongm2ez/larvel-mention
After installing the library, register the Dongm2ez\Mention\MentionServiceProvider
in your config/app.php
file:
'providers' => [
// Other service providers...
Dongm2ez\Mention\MentionServiceProvider::class,
],
As optional if you want to modify the default configuration, you can publish the configuration file:
$ php artisan vendor:publish --provider='Dongm2ez\Mention\MentionServiceProvider' --tag="config"
<?php
return [
// They contain the model that will be mentioned
'users' => [
// Model that will be mentioned
'model' => 'App\User',
// The column that will be used to search the model
'column' => 'name',
],
// Match the front mentioned info
'regex' => '/(\S*)\@([^\r\n\s]*)/i',
// laravel route alias
'route_name' => 'users.show',
// output format "html", "Markdown"
'format' => 'html',
];
$parseText = Mention::parse("@david @Aaron @Judy @麦索 Balabalabala...");
MIT