2022-05-29 16:19:04 -04:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2022-05-29 16:19:04 -04:00
|
|
|
namespace Pterodactyl\Models;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\WithoutTimestamps;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2025-12-20 15:55:13 -08:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
2022-05-29 16:19:04 -04:00
|
|
|
|
|
|
|
|
/**
|
2026-10-11 22:55:07 -04:00
|
|
|
* Larastan does not read #[Table], so it cannot find this model's columns.
|
2022-05-29 16:19:04 -04:00
|
|
|
*
|
|
|
|
|
* @property int $subject_id
|
|
|
|
|
* @property string $subject_type
|
|
|
|
|
*/
|
2026-10-05 18:10:18 -04:00
|
|
|
#[Guarded(['id'])]
|
|
|
|
|
#[Table(name: 'activity_log_subjects')]
|
|
|
|
|
#[WithoutTimestamps]
|
2022-05-29 16:19:04 -04:00
|
|
|
class ActivityLogSubject extends Pivot
|
|
|
|
|
{
|
|
|
|
|
public $incrementing = true;
|
|
|
|
|
|
2025-12-20 15:55:13 -08:00
|
|
|
/**
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return BelongsTo<ActivityLog, $this>
|
2025-12-20 15:55:13 -08:00
|
|
|
*/
|
|
|
|
|
public function activityLog(): BelongsTo
|
2022-05-29 16:19:04 -04:00
|
|
|
{
|
|
|
|
|
return $this->belongsTo(ActivityLog::class);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-20 15:55:13 -08:00
|
|
|
/**
|
2026-10-05 18:10:18 -04:00
|
|
|
* @return MorphTo<Model, $this>
|
2025-12-20 15:55:13 -08:00
|
|
|
*/
|
|
|
|
|
public function subject(): MorphTo
|
2022-05-29 16:19:04 -04:00
|
|
|
{
|
2022-06-05 18:28:08 -04:00
|
|
|
$morph = $this->morphTo();
|
2025-12-20 15:55:13 -08:00
|
|
|
if (method_exists($morph, 'withTrashed')) { // @phpstan-ignore function.alreadyNarrowedType
|
2022-06-05 18:28:08 -04:00
|
|
|
return $morph->withTrashed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $morph;
|
2022-05-29 16:19:04 -04:00
|
|
|
}
|
|
|
|
|
}
|