MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/public_html/mpl.imenso.co/app/Models/RadioShowMessage.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;

class RadioShowMessage extends Model
{
    public function author()
    {
        return $this->belongsTo(\App\Models\User::class, 'author_id');
    }

    public static function addNew($message_text)
    {
        $user_id = Auth::user()->id;
        $message = new self;
        $message->author_id = $user_id;
        $message->message_content = $message_text;

        if (RadioShow::currentShow() != null && $user_id == RadioShow::currentShow()->artist_id) {
            $message->host = 1;
        }

        $message->save();

        return $message;
    }

    public function formattedContent()
    {
        $content = nl2br(e($this->message_content));

        preg_match_all('/:+[a-z]+:/', $content, $matches, PREG_PATTERN_ORDER);

        foreach ($matches as $match) {
            foreach ($match as $inner_match) {
                $emoji = Emoji::where('shortcode', $inner_match)->first();

                if ($emoji != null) {
                    $content = str_replace($inner_match, '<i class="emoji" style="background-image:url(\''.$emoji->src.'\')"></i>', $content);
                }
            }
        }

        return $content;
    }
}