Files
UNIT3D-Community-Edition/app/Message.php
poppabear8883 f52662a061 (Alpha) Chat v2.0 (pusher only)
This is a "Alpha" commit. Its meant for Alpha testing. Features are
still being developed.

Please note, you must setup at least a FREE account with pusher and set
the corresponding fields in you `.env` file.

In the coming commits I will introducing a fallback so that once the
FREE pusher DAILY limits are reached, it will fall back to tradiational
database pulling every 3 seconds to get new messages.

There are still features that need to be added:
1. Emoji's
2. Statuses
3. User Tagging
4. Users List
5. Delete own messages, and staff moderation
and more ...
2018-05-03 21:32:59 -04:00

63 lines
1.3 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;
use Illuminate\Database\Eloquent\Model;
use App\Helpers\Bbcode;
class Message extends Model
{
protected $table = 'messages';
protected $with = ['user'];
/**
* Fields that are mass assignable
*
* @var array
*/
protected $fillable = [
'message',
'user_id',
'chatroom_id'
];
/**
* A message belongs to a user
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(\App\User::class);
}
/**
* A message belongs to a chatroom
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function chatroom()
{
return $this->belongsTo(\App\Chatroom::class);
}
/**
* Parse content and return valid HTML
*
*/
public static function getMessageHtml($message)
{
return Bbcode::parse($message);
}
}