Download the PHP package crixuamg/laravel-mentions without Composer
On this page you can find all versions of the php package crixuamg/laravel-mentions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crixuamg/laravel-mentions
More information about crixuamg/laravel-mentions
Files in crixuamg/laravel-mentions
Package laravel-mentions
Short Description A package to parse a @mention from a text and mention the user with a notification.
License MIT
Homepage https://github.com/CrixuAMG/Laravel-Mentions
Informations about the package laravel-mentions
Laravel Mentions
Travis Coverage Stable Version Downloads Laravel License A package to parse
@mentions
from a text and mention the user with a notification.By default this package is configured to parse any text type and it will replace any matched
@mention
with a markdown link ([@Mention](/users/profile/@Mention)
) if the mentionned user exist in the database. It will also send a notification with the LaravelNotifiable
trait to all mentionned users. (Inspired from the laravel-mentions package.)Quick example :
Input text :
Output text :
And Both
Admin
andMember
users will be notified. ButAdmin
will be notified only one time. (Yes the Parser include an anti-spam rule.)Table of Contents
- Requirement
- Installation
- ServiceProviders
- Vendor Publish
- Configuration
- Usage
- Parser configuration
- Parser configuration methods
- Custom Parser
- Notification
- Contribute
Requirement
Installation
ServiceProviders
Import the
MentionServiceProvider
in yourconfig/app.php
:Vendor Publish
Publish the vendor files to your application (included the config file
config/mentions.php
and the migration file) :Then migrate the database :
Configuration
Usage
First, you will need to add the
HasMentionTrait
to the mentioner Model :Now, you can start to parse a text in your controller or where you want :
And that's all ! At least with the default configuration. :stuck_out_tongue_closed_eyes:
Parser configuration
The
MentionParser
take a second parameter who is a configuration array, this is the default configuration :The configuration is merged with the default configuration, so you can set only the options that you want to modify. Exemple :
You can also set a configuration at the runtime :
Or even get a configuration option value :
Parser configuration methods :
The parser use the Xety/Configurator package to manage the configuration. Check this repository to get all the methods and their description.
Function Name Description setConfig(array $config)
Sets a configuration array.(Will replace all configuration options be carefull) getConfig()
Get all the configuration options. setOption(string $name, $value)
Set a value for the given key. getOption(string $name)
Get a configuration value. hasOption(string $name)
Determines if current instance has the given option. mergeConfig(array $values, bool $invert = false)
Merges configuration values with the new ones. If the $invert
param is set totrue
it will merge the default configuration into the$values
.Custom Parser
If you want more flexibility for the Parser, the best way is to create a new Parser and overwrite the methods that you want to modify. For an example, let's create a new Parser that will return a HTML link instead of a Markdown link :
To use it :
You can of course overwrite all Parser's methods if you need to.
Notification
You will need to write your own Notififation class, but I'm cool with you, you can find an example here using the delivery channel
database
:Contribute
If you want to contribute, please follow this guide.
All versions of laravel-mentions with dependencies
illuminate/console Version ^9.0
illuminate/database Version ^9.0
illuminate/http Version ^9.0
illuminate/validation Version ^9.0
illuminate/pagination Version ^9.0
illuminate/support Version ^9.0