2018-09-02 04:43:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Instance extends Model
|
|
|
|
{
|
2024-02-07 09:49:29 +00:00
|
|
|
protected $casts = [
|
|
|
|
'last_crawled_at' => 'datetime',
|
|
|
|
'actors_last_synced_at' => 'datetime',
|
|
|
|
'notes' => 'array',
|
|
|
|
'nodeinfo_last_fetched' => 'datetime',
|
|
|
|
'delivery_next_after' => 'datetime',
|
|
|
|
];
|
2019-01-20 23:25:12 +00:00
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
protected $fillable = [
|
|
|
|
'domain',
|
|
|
|
'banned',
|
|
|
|
'auto_cw',
|
|
|
|
'unlisted',
|
|
|
|
'notes'
|
|
|
|
];
|
2019-01-20 23:25:12 +00:00
|
|
|
|
2024-03-29 21:48:22 +00:00
|
|
|
// To get all moderated instances, we need to search where (banned OR unlisted)
|
|
|
|
public function scopeModerated($query): void {
|
|
|
|
$query->where(function ($query) {
|
|
|
|
$query->where('banned', true)->orWhere('unlisted', true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
public function profiles()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Profile::class, 'domain', 'domain');
|
|
|
|
}
|
2019-01-20 23:25:12 +00:00
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
public function statuses()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Status::class,
|
|
|
|
Profile::class,
|
|
|
|
'domain',
|
|
|
|
'profile_id',
|
|
|
|
'domain',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
2019-01-20 23:25:12 +00:00
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
public function reported()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Report::class,
|
|
|
|
Profile::class,
|
|
|
|
'domain',
|
|
|
|
'reported_profile_id',
|
|
|
|
'domain',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
2019-01-20 23:25:12 +00:00
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
public function reports()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Report::class,
|
|
|
|
Profile::class,
|
|
|
|
'domain',
|
|
|
|
'profile_id',
|
|
|
|
'domain',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
2019-01-21 03:53:35 +00:00
|
|
|
|
2024-02-07 09:49:29 +00:00
|
|
|
public function media()
|
|
|
|
{
|
|
|
|
return $this->hasManyThrough(
|
|
|
|
Media::class,
|
|
|
|
Profile::class,
|
|
|
|
'domain',
|
|
|
|
'profile_id',
|
|
|
|
'domain',
|
|
|
|
'id'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUrl()
|
|
|
|
{
|
|
|
|
return url("/i/admin/instances/show/{$this->id}");
|
|
|
|
}
|
2018-09-02 04:43:11 +00:00
|
|
|
}
|