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\Builder;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \Pterodactyl\Models\ActivityLogSubject.
|
|
|
|
|
*
|
|
|
|
|
* @property int $id
|
|
|
|
|
* @property int $activity_log_id
|
|
|
|
|
* @property int $subject_id
|
|
|
|
|
* @property string $subject_type
|
2024-10-21 19:18:20 -06:00
|
|
|
* @property ActivityLog|null $activityLog
|
2026-10-05 18:10:18 -04:00
|
|
|
* @property Model $subject
|
2022-05-29 16:19:04 -04:00
|
|
|
*
|
2026-10-05 18:10:18 -04:00
|
|
|
* @method static Builder|ActivityLogSubject newModelQuery()
|
|
|
|
|
* @method static Builder|ActivityLogSubject newQuery()
|
|
|
|
|
* @method static Builder|ActivityLogSubject query()
|
2022-10-14 10:59:20 -06:00
|
|
|
*
|
2026-10-05 18:10:18 -04:00
|
|
|
* @mixin Model
|
2022-05-29 16:19:04 -04:00
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
}
|