PHP code example of gaurav16694 / laravel-user-tagging
1. Go to this page and download the library: Download gaurav16694/laravel-user-tagging 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/ */
gaurav16694 / laravel-user-tagging 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 [
// 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',
// 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 gaurav\tagging\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);
}