2023-03-24 14:47:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
|
2023-03-24 14:47:58 +00:00
|
|
|
class PrivateKey extends BaseModel
|
|
|
|
{
|
2023-04-26 13:38:50 +00:00
|
|
|
protected $fillable = [
|
|
|
|
'name',
|
|
|
|
'description',
|
|
|
|
'private_key',
|
2023-06-19 08:58:00 +00:00
|
|
|
'is_git_related',
|
2023-04-26 13:38:50 +00:00
|
|
|
'team_id',
|
|
|
|
];
|
2023-06-16 10:05:52 +00:00
|
|
|
static public function ownedByCurrentTeam(array $select = ['*'])
|
2023-06-07 13:08:35 +00:00
|
|
|
{
|
2023-06-16 10:05:52 +00:00
|
|
|
$selectArray = collect($select)->concat(['id']);
|
2023-06-22 18:52:49 +00:00
|
|
|
return PrivateKey::whereTeamId(session('currentTeam')->id)->select($selectArray->all());
|
2023-06-07 13:08:35 +00:00
|
|
|
}
|
2023-06-19 07:44:39 +00: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);
|
|
|
|
}
|
2023-03-24 21:15:36 +00:00
|
|
|
public function servers()
|
|
|
|
{
|
2023-03-27 12:31:42 +00:00
|
|
|
return $this->hasMany(Server::class);
|
2023-03-24 14:47:58 +00:00
|
|
|
}
|
2023-06-19 07:44:39 +00: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;
|
|
|
|
}
|
2023-03-24 14:47:58 +00:00
|
|
|
}
|