pixelfed/app/Report.php

43 wiersze
849 B
PHP
Czysty Zwykły widok Historia

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;
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
return (new $class())->where($column, $this->object_id)->firstOrFail();
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
}
}