mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update Report model, add new methods
This commit is contained in:
parent
203034b971
commit
1a0661aec3
1 changed files with 38 additions and 0 deletions
38
app/Report.php
Normal file
38
app/Report.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Report extends Model
|
||||
{
|
||||
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');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue