mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
Add site redirects (#552)
* feat(redirects): add redirects to sites * chore(style): fixed coding style issues * style: fix php-stan docblocks * style: pint cleanup * tests: fixed redirect test suite * feat: vhosts include additional configs * fix: use exact location matching * - add enums - use queues - use vhost rather than separate conf files - vhost formatter - cleanup * generate docs --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
49
app/Models/Redirect.php
Normal file
49
app/Models/Redirect.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\RedirectStatus;
|
||||
use Database\Factories\RedirectFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $site_id
|
||||
* @property string $from
|
||||
* @property string $to
|
||||
* @property string $mode
|
||||
* @property string $status
|
||||
* @property Site $site
|
||||
*/
|
||||
class Redirect extends AbstractModel
|
||||
{
|
||||
/** @use HasFactory<RedirectFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'site_id',
|
||||
'from',
|
||||
'to',
|
||||
'mode',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public static array $statusColors = [
|
||||
RedirectStatus::CREATING => 'warning',
|
||||
RedirectStatus::READY => 'success',
|
||||
RedirectStatus::DELETING => 'warning',
|
||||
RedirectStatus::FAILED => 'danger',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Site, covariant $this>
|
||||
*/
|
||||
public function site(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\RedirectStatus;
|
||||
use App\Enums\SiteStatus;
|
||||
use App\Enums\SslStatus;
|
||||
use App\Exceptions\FailedToDestroyGitHook;
|
||||
@ -52,6 +53,8 @@
|
||||
* @property ?SourceControl $sourceControl
|
||||
* @property Collection<int, LoadBalancerServer> $loadBalancerServers
|
||||
* @property Project $project
|
||||
* @property Collection<int, Redirect> $redirects
|
||||
* @property Collection<int, Redirect> $activeRedirects
|
||||
*/
|
||||
class Site extends AbstractModel
|
||||
{
|
||||
@ -419,4 +422,20 @@ public function getSshUsers(): array
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Redirect, covariant $this>
|
||||
*/
|
||||
public function redirects(): HasMany
|
||||
{
|
||||
return $this->hasMany(Redirect::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Redirect, covariant $this>
|
||||
*/
|
||||
public function activeRedirects(): HasMany
|
||||
{
|
||||
return $this->redirects()->whereIn('status', [RedirectStatus::CREATING, RedirectStatus::READY]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user