mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 13:03:16 +00:00
Update Instance model, add entity casts
This commit is contained in:
parent
240e6bbe4f
commit
289cad470b
1 changed files with 67 additions and 53 deletions
120
app/Instance.php
120
app/Instance.php
|
@ -6,63 +6,77 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Instance extends Model
|
||||
{
|
||||
protected $fillable = ['domain', 'banned', 'auto_cw', 'unlisted', 'notes'];
|
||||
protected $casts = [
|
||||
'last_crawled_at' => 'datetime',
|
||||
'actors_last_synced_at' => 'datetime',
|
||||
'notes' => 'array',
|
||||
'nodeinfo_last_fetched' => 'datetime',
|
||||
'delivery_next_after' => 'datetime',
|
||||
];
|
||||
|
||||
public function profiles()
|
||||
{
|
||||
return $this->hasMany(Profile::class, 'domain', 'domain');
|
||||
}
|
||||
protected $fillable = [
|
||||
'domain',
|
||||
'banned',
|
||||
'auto_cw',
|
||||
'unlisted',
|
||||
'notes'
|
||||
];
|
||||
|
||||
public function statuses()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Status::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
public function profiles()
|
||||
{
|
||||
return $this->hasMany(Profile::class, 'domain', 'domain');
|
||||
}
|
||||
|
||||
public function reported()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Report::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'reported_profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
public function statuses()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Status::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Report::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
public function reported()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Report::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'reported_profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
|
||||
public function media()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Media::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Report::class,
|
||||
Profile::class,
|
||||
'domain',
|
||||
'profile_id',
|
||||
'domain',
|
||||
'id'
|
||||
);
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return url("/i/admin/instances/show/{$this->id}");
|
||||
}
|
||||
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}");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue