Files
vito/app/Models/Deployment.php
Saeed Vaziry c3f69f3247 #591 - sites
2025-06-04 08:08:20 +02:00

76 lines
1.7 KiB
PHP
Executable File

<?php
namespace App\Models;
use App\Enums\DeploymentStatus;
use Database\Factories\DeploymentFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $site_id
* @property int $deployment_script_id
* @property int $log_id
* @property string $commit_id
* @property string $commit_id_short
* @property array<string, mixed> $commit_data
* @property string $status
* @property Site $site
* @property DeploymentScript $deploymentScript
* @property ?ServerLog $log
*/
class Deployment extends AbstractModel
{
/** @use HasFactory<DeploymentFactory> */
use HasFactory;
protected $fillable = [
'site_id',
'deployment_script_id',
'log_id',
'commit_id',
'commit_data',
'status',
];
protected $casts = [
'site_id' => 'integer',
'deployment_script_id' => 'integer',
'log_id' => 'integer',
'commit_data' => 'json',
];
/**
* @var array<string, string>
*/
public static array $statusColors = [
DeploymentStatus::DEPLOYING => 'warning',
DeploymentStatus::FINISHED => 'success',
DeploymentStatus::FAILED => 'danger',
];
/**
* @return BelongsTo<Site, covariant $this>
*/
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
}
/**
* @return BelongsTo<DeploymentScript, covariant $this>
*/
public function deploymentScript(): BelongsTo
{
return $this->belongsTo(DeploymentScript::class);
}
/**
* @return BelongsTo<ServerLog, covariant $this>
*/
public function log(): BelongsTo
{
return $this->belongsTo(ServerLog::class, 'log_id');
}
}