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.
 
 
 
 

41 lines
919 B

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Member extends Model
{
public function save(array $options = [])
{
try {
parent::save($options);
} catch (\Exception $e) {
/*
* When a member is received by two accounts simultaenously
* in different processes they can be saved using the insert state
* in the DB causing an error
*/
}
}
public function contact()
{
return $this->hasOne('App\Contact', 'id', 'jid');
}
public function getTruenameAttribute(): string
{
if ($this->contact && $this->contact->truename) {
return $this->contact->truename;
}
return explodeJid($this->jid)['username'] ?? $this->jid;
}
public function getColorAttribute(): string
{
return stringToColor($this->jid);
}
}