1. Go to this page and download the library: Download votong/laravel-mentions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
votong / laravel-mentions example snippets
// Mention a single user
$comment->mention($user);
// Mention a collection of users
$comment->mention($users);
// Handle the form data
$comment->mention($request->mentions);
// Get all mentions, resolved to their models
$comment->mentions();
// Unmention a single user
$comment->unmention($user);
// Unmention a collection of users
$comment->unmention($users);
return [
// The middleware that should be applied to all
// routes that are registered in this package.
'middleware' => null,
// Pools are what you reference on the front-end
// They contain the model that will be mentioned
'pools' => [
'users' => [
// Model that will be mentioned
'model' => 'App\User',
// Filter class that alters the query
'filter' => null,
// The column that will be used to search the model
'column' => 'name',
// Notification class to use when this model is mentioned
'notification' => 'App\Notifications\UserMentioned',
// Automatically notify upon mentions
'auto_notify' => true
]
]
];
namespace App;
use Illuminate\Database\Eloquent\Model;
use VoTong\Mentions\Traits\HasMentions;
class Comment extends Model
{
use HasMentions;
}
public function store(Request $request)
{
// Handle the comment creation however you like
$comment = Comment::create($request->all());
// Call the mention method with the form mentions data
$comment->mention($request->mentions);
}
namespace App\Filters;
class UserFilter
{
/**
* Handles the filtering and returns the updated query.
*
* @return Illuminate\Database\Eloquent\Builder
*/
public static function handle($query)
{
// Apply your filters here!
return $query->where('someColumn', 'someValue');
}
}