mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 19:36:02 -05:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
|
|
|
/**
|
|
* Larastan does not read #[Table], so it cannot find this model's columns.
|
|
*
|
|
* @property int $subject_id
|
|
* @property string $subject_type
|
|
*/
|
|
#[Guarded(['id'])]
|
|
#[Table(name: 'activity_log_subjects')]
|
|
#[WithoutTimestamps]
|
|
class ActivityLogSubject extends Pivot
|
|
{
|
|
public $incrementing = true;
|
|
|
|
/**
|
|
* @return BelongsTo<ActivityLog, $this>
|
|
*/
|
|
public function activityLog(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ActivityLog::class);
|
|
}
|
|
|
|
/**
|
|
* @return MorphTo<Model, $this>
|
|
*/
|
|
public function subject(): MorphTo
|
|
{
|
|
$morph = $this->morphTo();
|
|
if (method_exists($morph, 'withTrashed')) { // @phpstan-ignore function.alreadyNarrowedType
|
|
return $morph->withTrashed();
|
|
}
|
|
|
|
return $morph;
|
|
}
|
|
}
|