mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-21 09:20:08 -05:00
85 lines
1.7 KiB
PHP
85 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D
|
|
*
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
* @author HDVinnie
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Helpers\Bbcode;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Message extends Model
|
|
{
|
|
/**
|
|
* The Attributes That Are Mass Assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'message',
|
|
'user_id',
|
|
'chatroom_id',
|
|
'receiver_id',
|
|
'bot_id',
|
|
];
|
|
|
|
/**
|
|
* Belongs To A Bot.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function bot()
|
|
{
|
|
return $this->belongsTo(Bot::class);
|
|
}
|
|
|
|
/**
|
|
* Belongs To A User.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* A message belongs to a receiver.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function receiver()
|
|
{
|
|
return $this->belongsTo(User::class, 'receiver_id');
|
|
}
|
|
|
|
/**
|
|
* Belongs To A Chat Room.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function chatroom()
|
|
{
|
|
return $this->belongsTo(Chatroom::class);
|
|
}
|
|
|
|
/**
|
|
* Parse Content And Return Valid HTML.
|
|
*
|
|
* @param $message
|
|
* @return string Parsed BBCODE To HTML
|
|
*/
|
|
public static function getMessageHtml($message)
|
|
{
|
|
return Bbcode::parse($message);
|
|
}
|
|
}
|