You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/app/Models/Report.php

101 lines
3.5 KiB
PHTML

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
4 days ago
use Illuminate\Support\Carbon;
4 days ago
/**
* @property int $id
* @property int $profile_id
* @property int|null $user_id
* @property int $object_id
* @property string|null $object_type
* @property int|null $reported_profile_id
* @property string|null $type
* @property string|null $message
4 days ago
* @property Carbon|null $admin_seen
4 days ago
* @property int $not_interested
* @property int $spam
* @property int $nsfw
* @property int $abusive
* @property string|null $meta
4 days ago
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read Profile|null $reportedUser
* @property-read Profile|null $reporter
* @property-read Status|null $status
*
4 days ago
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereAbusive($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereAdminSeen($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereMeta($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereNotInterested($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereNsfw($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereObjectId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereObjectType($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereProfileId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereReportedProfileId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereSpam($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Report whereUserId($value)
4 days ago
*
4 days ago
* @mixin \Eloquent
*/
class Report extends Model
{
4 years ago
protected $guarded = [];
7 months ago
protected function casts(): array
{
return [
'admin_seen' => 'datetime',
];
}
public function url()
{
return url('/i/admin/reports/show/'.$this->id);
}
public function reporter(): BelongsTo
{
return $this->belongsTo(Profile::class, 'profile_id');
}
public function reported()
{
$class = $this->object_type;
switch ($class) {
case Status::class:
9 months ago
$column = 'id';
break;
default:
$class = Status::class;
9 months ago
$column = 'id';
break;
}
9 months ago
return (new $class)->where($column, $this->object_id)->first();
}
public function status(): BelongsTo
{
return $this->belongsTo(Status::class, 'object_id');
}
public function reportedUser(): BelongsTo
{
return $this->belongsTo(Profile::class, 'reported_profile_id', 'id');
}
}