* @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 */ 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 */ 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 */ 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 */ 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 */ public function staff(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class, 'staff_id')->withDefault([ 'username' => 'System', 'id' => User::SYSTEM_USER_ID, ]); } }