https://github.com/unicodeveloper/laravel-mentions
:couple: :package: Laravel 5 Package for enabling facebook type of mentions in your application
https://github.com/unicodeveloper/laravel-mentions
Last synced: 6 months ago
JSON representation
:couple: :package: Laravel 5 Package for enabling facebook type of mentions in your application
- Host: GitHub
- URL: https://github.com/unicodeveloper/laravel-mentions
- Owner: unicodeveloper
- License: mit
- Created: 2015-09-19T13:58:02.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-09T17:21:10.000Z (over 9 years ago)
- Last Synced: 2025-04-15T11:42:30.872Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 64
- Watchers: 5
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# laravel-mentions
[](https://packagist.org/packages/unicodeveloper/laravel-mentions)

[](LICENSE.md)
[](https://travis-ci.org/unicodeveloper/laravel-mentions)
[](https://scrutinizer-ci.com/g/unicodeveloper/laravel-mentions)
[](https://packagist.org/packages/unicodeveloper/laravel-mentions)
This package makes it possible to create text/textarea fields that enable **mentioning** by using [At.js](https://github.com/ichord/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.
```js
"require": {
"unicodeveloper/laravel-mentions": "1.1.*"
}
```
And then include these service providers within `config/app.php`.
```php
'providers' => [
Unicodeveloper\Mention\MentionServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
];
```
If you need to modify the configuration or the views, you can run:
```bash
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.
```php
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.
```php
{!! 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`
```php
{!! mention()->asText('recipient', old('recipient'), 'users', 'name', 'user-form') !!}
```
## Example
```html
Laravel PHP Framework
@include('mentions::assets')
{!! mention()->asText('recipient', old('recipient'), 'users', 'name') !!}
{!! mention()->asTextArea('message', old('message'), 'users', 'name') !!}
```
## Install
Via Composer
``` bash
$ composer require unicodeveloper/laravel-mentions
```
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) 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](https://twitter.com/unicodeveloper)!
Thanks!
Prosper Otemuyiwa.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.