Files
UNIT3D/app/Models/Report.php
Roardom b2e29cfcf0 fix: migrate boolean columns to tinyint(1)
These columns were previously tiny ints without the (1) display width or regular ints, or smallints. They should all be tinyint(1).
2025-02-19 06:25:21 +00:00

127 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Models;
use App\Traits\Auditable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Report.
*
* @property int $id
* @property string $type
* @property int $reporter_id
* @property int|null $staff_id
* @property string $title
* @property string $message
* @property bool $solved
* @property string|null $verdict
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int|null $reported_user
* @property int|null $torrent_id
* @property int|null $request_id
* @property \Illuminate\Support\Carbon|null $snoozed_until
*/
class Report extends Model
{
use Auditable;
/** @use HasFactory<\Database\Factories\ReportFactory> */
use HasFactory;
/**
* The attributes that aren't mass assignable.
*
* @var string[]
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Get the attributes that should be cast.
*
* @return array{solved: 'bool', snoozed_until: 'datetime'}
*/
protected function casts(): array
{
return [
'solved' => 'bool',
'snoozed_until' => 'datetime',
];
}
/**
* Belongs To A Request.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<TorrentRequest, $this>
*/
public function request(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(TorrentRequest::class, 'request_id');
}
/**
* Belongs To A Torrent.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Torrent, $this>
*/
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Torrent::class, 'torrent_id');
}
/**
* Belongs To A User.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function reporter(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class, 'reporter_id')->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
/**
* Belongs To A User.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function reported(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class, 'reported_user')->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
/**
* Belongs To A Staff Member.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function staff(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class, 'staff_id')->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
}