1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2025-03-04 18:48:21 +00:00
pixelfed/app/Report.php

49 lines
947 B
PHP
Raw Normal View History

2018-08-09 20:57:52 -06:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
2018-08-26 00:00:20 -06:00
protected $dates = ['admin_seen'];
2018-08-28 03:07:36 +00:00
2018-08-09 20:57:52 -06:00
public function url()
{
2018-08-28 03:07:36 +00:00
return url('/i/admin/reports/show/'.$this->id);
2018-08-09 20:57:52 -06:00
}
public function reporter()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'profile_id');
2018-08-09 20:57:52 -06:00
}
public function reported()
{
2018-08-28 03:07:36 +00:00
$class = $this->object_type;
2020-01-22 20:05:40 -07:00
2018-08-28 03:07:36 +00:00
switch ($class) {
2018-11-03 21:25:26 -06:00
case 'App\Status':
$column = 'id';
break;
default:
$class = 'App\Status';
$column = 'id';
break;
}
2018-08-28 03:07:36 +00:00
2020-01-22 20:05:40 -07:00
return (new $class())->where($column, $this->object_id)->first();
}
public function status()
{
return $this->belongsTo(Status::class, 'object_id');
2018-08-09 20:57:52 -06:00
}
public function reportedUser()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'reported_profile_id', 'id');
2018-08-09 20:57:52 -06:00
}
}