1 year ago

Mention a user

Posted 1 year ago by Larasou

Hi people, I have a little problem, I followed the series on building a forum.

In the part where you have to mention the name of a user after an @, is problematic.

Because when I put a code on my site and that includes comments of the style:

     * Set the body attribute.
     * @param string $body
    public function setBodyAttribute($body)
        $this->attributes['body'] = preg_replace(
            '/@([^\s]+(?=(?:\.$) |\b))/',
            '<a href="/profile/" class="font-bold text-violet">LARACASTS_SNIPPET_PLACEHOLDER</a>',

He will also look for @param to give him a link.

Is there a way to select only users?

Please sign in or create an account to participate in this conversation.