1
0
Fork 0
forked from mirror/pixelfed
pixelfed/app/Report.php

41 lines
788 B
PHP
Raw Normal View History

2018-08-10 02:57:52 +00:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
2018-08-26 06:00:20 +00:00
protected $dates = ['admin_seen'];
2018-08-10 02:57:52 +00:00
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:
$column = 'id';
break;
}
return (new $class())->where($column, $this->object_id)->firstOrFail();
}
public function reportedUser()
{
return $this->belongsTo(Profile::class, 'reported_profile_id', 'id');
}
}