1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 00:05:29 +00:00
pixelfed/app/Report.php

53 lines
1,002 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
{
2023-04-20 04:30:37 +00:00
protected $casts = [
'admin_seen' => 'datetime'
];
2018-08-28 03:07:36 +00:00
2023-01-21 14:48:27 +00:00
protected $guarded = [];
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
}
}