mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Update Status model
This commit is contained in:
parent
d99d7e7c19
commit
bd503e5a57
1 changed files with 37 additions and 0 deletions
|
@ -20,6 +20,19 @@ class Status extends Model
|
||||||
|
|
||||||
protected $fillable = ['profile_id', 'visibility', 'in_reply_to_id'];
|
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()
|
public function profile()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Profile::class);
|
return $this->belongsTo(Profile::class);
|
||||||
|
@ -108,6 +121,18 @@ class Status extends Model
|
||||||
return Like::whereProfileId($profile->id)->whereStatusId($this->id)->count();
|
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()
|
public function comments()
|
||||||
{
|
{
|
||||||
return $this->hasMany(self::class, 'in_reply_to_id');
|
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();
|
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()
|
public function parent()
|
||||||
{
|
{
|
||||||
$parent = $this->in_reply_to_id ?? $this->reblog_of_id;
|
$parent = $this->in_reply_to_id ?? $this->reblog_of_id;
|
||||||
|
|
Loading…
Reference in a new issue