Skip to content

Commit 289cad4

Browse files
committed
Update Instance model, add entity casts
1 parent 240e6bb commit 289cad4

File tree

1 file changed

+67
-53
lines changed

1 file changed

+67
-53
lines changed

app/Instance.php

+67-53
Original file line numberDiff line numberDiff line change
@@ -6,63 +6,77 @@
66

77
class Instance extends Model
88
{
9-
protected $fillable = ['domain', 'banned', 'auto_cw', 'unlisted', 'notes'];
9+
protected $casts = [
10+
'last_crawled_at' => 'datetime',
11+
'actors_last_synced_at' => 'datetime',
12+
'notes' => 'array',
13+
'nodeinfo_last_fetched' => 'datetime',
14+
'delivery_next_after' => 'datetime',
15+
];
1016

11-
public function profiles()
12-
{
13-
return $this->hasMany(Profile::class, 'domain', 'domain');
14-
}
17+
protected $fillable = [
18+
'domain',
19+
'banned',
20+
'auto_cw',
21+
'unlisted',
22+
'notes'
23+
];
1524

16-
public function statuses()
17-
{
18-
return $this->hasManyThrough(
19-
Status::class,
20-
Profile::class,
21-
'domain',
22-
'profile_id',
23-
'domain',
24-
'id'
25-
);
26-
}
25+
public function profiles()
26+
{
27+
return $this->hasMany(Profile::class, 'domain', 'domain');
28+
}
2729

28-
public function reported()
29-
{
30-
return $this->hasManyThrough(
31-
Report::class,
32-
Profile::class,
33-
'domain',
34-
'reported_profile_id',
35-
'domain',
36-
'id'
37-
);
38-
}
30+
public function statuses()
31+
{
32+
return $this->hasManyThrough(
33+
Status::class,
34+
Profile::class,
35+
'domain',
36+
'profile_id',
37+
'domain',
38+
'id'
39+
);
40+
}
3941

40-
public function reports()
41-
{
42-
return $this->hasManyThrough(
43-
Report::class,
44-
Profile::class,
45-
'domain',
46-
'profile_id',
47-
'domain',
48-
'id'
49-
);
50-
}
42+
public function reported()
43+
{
44+
return $this->hasManyThrough(
45+
Report::class,
46+
Profile::class,
47+
'domain',
48+
'reported_profile_id',
49+
'domain',
50+
'id'
51+
);
52+
}
5153

52-
public function media()
53-
{
54-
return $this->hasManyThrough(
55-
Media::class,
56-
Profile::class,
57-
'domain',
58-
'profile_id',
59-
'domain',
60-
'id'
61-
);
62-
}
54+
public function reports()
55+
{
56+
return $this->hasManyThrough(
57+
Report::class,
58+
Profile::class,
59+
'domain',
60+
'profile_id',
61+
'domain',
62+
'id'
63+
);
64+
}
6365

64-
public function getUrl()
65-
{
66-
return url("/i/admin/instances/show/{$this->id}");
67-
}
66+
public function media()
67+
{
68+
return $this->hasManyThrough(
69+
Media::class,
70+
Profile::class,
71+
'domain',
72+
'profile_id',
73+
'domain',
74+
'id'
75+
);
76+
}
77+
78+
public function getUrl()
79+
{
80+
return url("/i/admin/instances/show/{$this->id}");
81+
}
6882
}

0 commit comments

Comments
 (0)