dongm2ez / larvel-mention

此包已被弃用且不再维护。未建议替代包。

一个laravel用户提及的包

1.0.1 2017-07-26 02:36 UTC

This package is not auto-updated.

Last update: 2021-10-30 12:14:38 UTC


README

❤️ 此包帮助您完成 @ 函数

Latest Stable Version Latest Unstable Version Total Downloads License

要求

  • PHP >= 5.4.0

安装

$ composer require dongm2ez/larvel-mention

安装库后,在您的 config/app.php 文件中注册 Dongm2ez\Mention\MentionServiceProvider

'providers' => [
    // Other service providers...
    Dongm2ez\Mention\MentionServiceProvider::class,
],

可选:如果您想修改默认配置,可以发布配置文件

$ 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