1
0
Fork 0
pixelfed/app/Report.php

49 lines
947 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-28 03:07:36 +00:00
2018-08-10 02:57:52 +00:00
public function url()
{
2018-08-28 03:07:36 +00:00
return url('/i/admin/reports/show/'.$this->id);
2018-08-10 02:57:52 +00:00
}
public function reporter()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'profile_id');
2018-08-10 02:57:52 +00:00
}
public function reported()
{
2018-08-28 03:07:36 +00:00
$class = $this->object_type;
2020-01-23 03:05:40 +00:00
2018-08-28 03:07:36 +00:00
switch ($class) {
2018-11-04 03:25:26 +00:00
case 'App\Status':
$column = 'id';
break;
default:
$class = 'App\Status';
$column = 'id';
break;
}
2018-08-28 03:07:36 +00:00
2020-01-23 03:05:40 +00:00
return (new $class())->where($column, $this->object_id)->first();
}
public function status()
{
return $this->belongsTo(Status::class, 'object_id');
2018-08-10 02:57:52 +00:00
}
public function reportedUser()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'reported_profile_id', 'id');
2018-08-10 02:57:52 +00:00
}
}