coolify/app/Models/PrivateKey.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Models;
2023-06-07 15:08:35 +02:00
class PrivateKey extends BaseModel
{
protected $fillable = [
'name',
'description',
'private_key',
2023-06-19 10:58:00 +02:00
'is_git_related',
'team_id',
];
2023-06-16 12:05:52 +02:00
static public function ownedByCurrentTeam(array $select = ['*'])
2023-06-07 15:08:35 +02:00
{
2023-06-16 12:05:52 +02:00
$selectArray = collect($select)->concat(['id']);
2023-06-22 20:52:49 +02:00
return PrivateKey::whereTeamId(session('currentTeam')->id)->select($selectArray->all());
2023-06-07 15:08:35 +02:00
}
2023-06-19 09:44:39 +02:00
public function applications()
{
return $this->hasMany(Application::class);
}
public function githubApps()
{
return $this->hasMany(GithubApp::class);
}
public function gitlabApps()
{
return $this->hasMany(GitlabApp::class);
}
public function servers()
{
2023-03-27 14:31:42 +02:00
return $this->hasMany(Server::class);
}
2023-06-19 09:44:39 +02:00
public function isEmpty()
{
if ($this->servers()->count() === 0 && $this->applications()->count() === 0 && $this->githubApps()->count() === 0 && $this->gitlabApps()->count() === 0) {
return true;
}
return false;
}
}