mirror of https://github.com/movim/movim
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
779 B
38 lines
779 B
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Reaction extends Model
|
|
{
|
|
protected $primaryKey = 'message_mid';
|
|
|
|
protected $casts = [
|
|
'created_at' => 'datetime:Y-m-d H:i:s',
|
|
'updated_at' => 'datetime:Y-m-d H:i:s',
|
|
];
|
|
|
|
public function message()
|
|
{
|
|
return $this->belongsTo(Message::class);
|
|
}
|
|
|
|
public function contact()
|
|
{
|
|
return $this->hasOne(Contact::class, 'id', 'jidfrom');
|
|
}
|
|
|
|
public function getTruenameAttribute()
|
|
{
|
|
if ($this->contact) {
|
|
return $this->contact->truename;
|
|
}
|
|
|
|
if (str_contains($this->jidfrom, '@')) {
|
|
return explodeJid($this->jidfrom)['username'];
|
|
} else {
|
|
return $this->jidfrom;
|
|
}
|
|
}
|
|
}
|