unicodeveloper/laravel-mentions
Composer 安装命令:
composer require unicodeveloper/laravel-mentions
包简介
Laravel 5 package that provides facebook-like mention functionality
README 文档
README
This package makes it possible to create text/textarea fields that enable mentioning by using At.js.
The data for the autocomplete is loaded from a route which will load data based on predefined key-value pairs of an alias and a model in the config.
Installation
First, pull in the package through Composer.
"require": { "unicodeveloper/laravel-mentions": "1.1.*" }
And then include these service providers within config/app.php.
'providers' => [ Unicodeveloper\Mention\MentionServiceProvider::class, Collective\Html\HtmlServiceProvider::class, ];
If you need to modify the configuration or the views, you can run:
php artisan vendor:publish
The package views will now be located in the app/resources/views/vendor/mentions/ directory and the configuration will be located at config/mentions.php.
Configuration
To make it possible for At.js to load data we need to define key-value pairs that consist of an alias and a corresponding model.
return [ 'users' => 'App\User', // responds to /api/mentions/users 'friends' => 'App\Friend', // responds to /api/mentions/friends 'clients' => 'App\Client', // responds to /api/mentions/clients 'supports' => 'App\Supporter', // responds to /api/mentions/supports ];
So now with these aliases configured we could create a new textfield which will send a request to the users route and search for matching data in the name column.
{!! mention()->asText('recipient', old('recipient'), 'users', 'name') !!}
You can also add a class name for styling of the text and textareas, that's the last argument. In this example, it is user-form
{!! mention()->asText('recipient', old('recipient'), 'users', 'name', 'user-form') !!}
Example
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Laravel PHP Framework</title> <link rel="stylesheet" type="text/css" href="/css/jquery.atwho.min.css"> <!-- Requirements --> <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> <script src="/js/jquery.atwho.min.js"></script> <script src="/js/jquery.caret.min.js"></script> <!-- Laravel Mentions --> @include('mentions::assets') </head> <body> <div class="container"> {!! mention()->asText('recipient', old('recipient'), 'users', 'name') !!} {!! mention()->asTextArea('message', old('message'), 'users', 'name') !!} </div><!-- /.container --> </body> </html>
Install
Via Composer
$ composer require unicodeveloper/laravel-mentions
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
How can I thank you?
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!
Don't forget to follow me on twitter!
Thanks! Prosper Otemuyiwa.
License
The MIT License (MIT). Please see License File for more information.
unicodeveloper/laravel-mentions 适用场景与选型建议
unicodeveloper/laravel-mentions 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 977 次下载、GitHub Stars 达 63, 最近一次更新时间为 2015 年 11 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「autocomplete」 「laravel」 「laravel 5」 「laravel-mentions」 「facebook-mentions」 「smart search」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 unicodeveloper/laravel-mentions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 unicodeveloper/laravel-mentions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 unicodeveloper/laravel-mentions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Cassandra php driver library IDE stubs which enables autocompletion in modern IDEs.
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Dadata API client (https://dadata.ru)
Yii2 Jui AutoComplete with Id field widget
Alfabank REST API integration
Raylib runtime & extensions header files for PhpStorm
统计信息
- 总下载量: 977
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 64
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-04