122 lines
2.8 KiB
PHP
122 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Support\Concerns\DerivesWorkspaceIdFromTenant;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class SupportRequest extends Model
|
|
{
|
|
use DerivesWorkspaceIdFromTenant;
|
|
|
|
/** @use HasFactory<\Database\Factories\SupportRequestFactory> */
|
|
use HasFactory;
|
|
|
|
public const string PRIMARY_CONTEXT_TENANT = 'tenant';
|
|
|
|
public const string PRIMARY_CONTEXT_OPERATION_RUN = 'operation_run';
|
|
|
|
public const string ATTACHMENT_MODE_DIAGNOSTIC_SNAPSHOT_ATTACHED = 'diagnostic_snapshot_attached';
|
|
|
|
public const string ATTACHMENT_MODE_CANONICAL_CONTEXT_ONLY = 'canonical_context_only';
|
|
|
|
public const string SEVERITY_LOW = 'low';
|
|
|
|
public const string SEVERITY_NORMAL = 'normal';
|
|
|
|
public const string SEVERITY_HIGH = 'high';
|
|
|
|
public const string SEVERITY_BLOCKING = 'blocking';
|
|
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'context_envelope' => 'array',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public static function severityOptions(): array
|
|
{
|
|
return [
|
|
self::SEVERITY_LOW => 'Low',
|
|
self::SEVERITY_NORMAL => 'Normal',
|
|
self::SEVERITY_HIGH => 'High',
|
|
self::SEVERITY_BLOCKING => 'Blocking',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function severityValues(): array
|
|
{
|
|
return array_keys(self::severityOptions());
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function primaryContextTypes(): array
|
|
{
|
|
return [
|
|
self::PRIMARY_CONTEXT_TENANT,
|
|
self::PRIMARY_CONTEXT_OPERATION_RUN,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public static function attachmentModes(): array
|
|
{
|
|
return [
|
|
self::ATTACHMENT_MODE_DIAGNOSTIC_SNAPSHOT_ATTACHED,
|
|
self::ATTACHMENT_MODE_CANONICAL_CONTEXT_ONLY,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Workspace, $this>
|
|
*/
|
|
public function workspace(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Workspace::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Tenant, $this>
|
|
*/
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<OperationRun, $this>
|
|
*/
|
|
public function operationRun(): BelongsTo
|
|
{
|
|
return $this->belongsTo(OperationRun::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function initiator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'initiated_by_user_id');
|
|
}
|
|
}
|