43 lines
984 B
PHP
43 lines
984 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\RepositoryType;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
class Application extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'repository_type' => RepositoryType::class,
|
|
];
|
|
}
|
|
|
|
public function organisation(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organisation::class);
|
|
}
|
|
|
|
public function instances(): HasMany
|
|
{
|
|
return $this->hasMany(Instance::class);
|
|
}
|
|
|
|
public function servers(): HasManyThrough
|
|
{
|
|
return $this->hasManyThrough(Server::class, Instance::class);
|
|
}
|
|
|
|
public function deployments(): MorphMany
|
|
{
|
|
return $this->morphMany(Deployment::class, 'target');
|
|
}
|
|
}
|