Automated PR provided by Codex via Gitea API. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #482
72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Support\TenantConfiguration\ClaimState;
|
|
use App\Support\TenantConfiguration\EvidenceState;
|
|
use App\Support\TenantConfiguration\IdentityState;
|
|
use App\Support\TenantConfiguration\SourceClass;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class TenantConfigurationResource extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'source_class' => SourceClass::class,
|
|
'source_metadata' => 'array',
|
|
'latest_evidence_state' => EvidenceState::class,
|
|
'latest_identity_state' => IdentityState::class,
|
|
'latest_claim_state' => ClaimState::class,
|
|
'latest_captured_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function workspace(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Workspace::class);
|
|
}
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ManagedEnvironment::class, 'managed_environment_id');
|
|
}
|
|
|
|
public function managedEnvironment(): BelongsTo
|
|
{
|
|
return $this->tenant();
|
|
}
|
|
|
|
public function providerConnection(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProviderConnection::class);
|
|
}
|
|
|
|
public function resourceType(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TenantConfigurationResourceType::class);
|
|
}
|
|
|
|
public function latestEvidence(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TenantConfigurationResourceEvidence::class, 'latest_evidence_id');
|
|
}
|
|
|
|
public function evidence(): HasMany
|
|
{
|
|
return $this->hasMany(TenantConfigurationResourceEvidence::class, 'resource_id');
|
|
}
|
|
}
|