mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 02:24:31 +00:00
53 lines
1,002 B
PHP
53 lines
1,002 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Report extends Model
|
|
{
|
|
protected $casts = [
|
|
'admin_seen' => 'datetime'
|
|
];
|
|
|
|
protected $guarded = [];
|
|
|
|
public function url()
|
|
{
|
|
return url('/i/admin/reports/show/'.$this->id);
|
|
}
|
|
|
|
public function reporter()
|
|
{
|
|
return $this->belongsTo(Profile::class, 'profile_id');
|
|
}
|
|
|
|
public function reported()
|
|
{
|
|
$class = $this->object_type;
|
|
|
|
switch ($class) {
|
|
case 'App\Status':
|
|
$column = 'id';
|
|
break;
|
|
|
|
default:
|
|
$class = 'App\Status';
|
|
$column = 'id';
|
|
break;
|
|
}
|
|
|
|
return (new $class())->where($column, $this->object_id)->first();
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
return $this->belongsTo(Status::class, 'object_id');
|
|
}
|
|
|
|
public function reportedUser()
|
|
{
|
|
return $this->belongsTo(Profile::class, 'reported_profile_id', 'id');
|
|
}
|
|
}
|