|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
|
|
use Storage;
|
|
|
|
|
use Auth, Storage;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
@ -71,15 +71,39 @@ class Status extends Model
|
|
|
|
|
return $this->hasMany(Like::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function liked() : bool
|
|
|
|
|
{
|
|
|
|
|
$profile = Auth::user()->profile;
|
|
|
|
|
return Like::whereProfileId($profile->id)->whereStatusId($this->id)->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function comments()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Status::class, 'in_reply_to_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function bookmarked()
|
|
|
|
|
{
|
|
|
|
|
$profile = Auth::user()->profile;
|
|
|
|
|
return Bookmark::whereProfileId($profile->id)->whereStatusId($this->id)->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function shares()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Status::class, 'reblog_of_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function shared() : bool
|
|
|
|
|
{
|
|
|
|
|
$profile = Auth::user()->profile;
|
|
|
|
|
return Status::whereProfileId($profile->id)->whereReblogOfId($this->id)->count();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function parent()
|
|
|
|
|
{
|
|
|
|
|
if(!empty($this->in_reply_to_id)) {
|
|
|
|
|
return Status::findOrFail($this->in_reply_to_id);
|
|
|
|
|
$parent = $this->in_reply_to_id ?? $this->reblog_of_id;
|
|
|
|
|
if(!empty($parent)) {
|
|
|
|
|
return Status::findOrFail($parent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -100,6 +124,23 @@ class Status extends Model
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function mentions()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
|
Profile::class,
|
|
|
|
|
Mention::class,
|
|
|
|
|
'status_id',
|
|
|
|
|
'id',
|
|
|
|
|
'id',
|
|
|
|
|
'profile_id'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function reportUrl()
|
|
|
|
|
{
|
|
|
|
|
return route('report.form') . "?type=post&id={$this->id}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toActivityStream()
|
|
|
|
|
{
|
|
|
|
|
$media = $this->media;
|
|
|
|
|