Update Status model

This commit is contained in:
Daniel Supernault 2018-12-01 21:02:26 -07:00
parent d99d7e7c19
commit bd503e5a57
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 37 additions and 0 deletions

View File

@ -20,6 +20,19 @@ class Status extends Model
protected $fillable = ['profile_id', 'visibility', 'in_reply_to_id'];
const STATUS_TYPES = [
'photo',
'photo:album',
'video',
'video:album',
'share',
'reply',
'story',
'story:reply',
'story:reaction',
'story:live'
];
public function profile()
{
return $this->belongsTo(Profile::class);
@ -108,6 +121,18 @@ class Status extends Model
return Like::whereProfileId($profile->id)->whereStatusId($this->id)->count();
}
public function likedBy()
{
return $this->hasManyThrough(
Profile::class,
Like::class,
'status_id',
'id',
'id',
'profile_id'
);
}
public function comments()
{
return $this->hasMany(self::class, 'in_reply_to_id');
@ -138,6 +163,18 @@ class Status extends Model
return self::whereProfileId($profile->id)->whereReblogOfId($this->id)->count();
}
public function sharedBy()
{
return $this->hasManyThrough(
Profile::class,
Status::class,
'reblog_of_id',
'id',
'id',
'profile_id'
);
}
public function parent()
{
$parent = $this->in_reply_to_id ?? $this->reblog_of_id;