woah
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class PrivateKey extends BaseModel
|
||||
{
|
||||
protected $fillable = [
|
||||
@@ -10,6 +11,10 @@ class PrivateKey extends BaseModel
|
||||
'private_key',
|
||||
'team_id',
|
||||
];
|
||||
static public function ownedByCurrentTeam()
|
||||
{
|
||||
return PrivateKey::whereTeamId(session('currentTeam')->id);
|
||||
}
|
||||
public function servers()
|
||||
{
|
||||
return $this->hasMany(Server::class);
|
||||
|
||||
@@ -22,6 +22,11 @@ class Project extends BaseModel
|
||||
'team_id',
|
||||
'project_id'
|
||||
];
|
||||
static public function ownedByCurrentTeam()
|
||||
{
|
||||
return Project::whereTeamId(session('currentTeam')->id);
|
||||
}
|
||||
|
||||
public function environments()
|
||||
{
|
||||
return $this->hasMany(Environment::class);
|
||||
|
||||
@@ -53,28 +53,21 @@ class Server extends BaseModel
|
||||
{
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
}
|
||||
static public function ownedByCurrentTeam()
|
||||
{
|
||||
return Server::whereTeamId(session('currentTeam')->id);
|
||||
}
|
||||
|
||||
static public function validated()
|
||||
{
|
||||
return Server::where('team_id', session('currentTeam')->id)->whereRelation('settings', 'is_validated', true)->get();
|
||||
return Server::ownedByCurrentTeam()->whereRelation('settings', 'is_validated', true);
|
||||
}
|
||||
|
||||
static public function destinations(string|null $server_id = null)
|
||||
static public function destinationsByServer(string $server_id)
|
||||
{
|
||||
if ($server_id) {
|
||||
$server = Server::where('team_id', session('currentTeam')->id)->where('id', $server_id)->firstOrFail();
|
||||
$standaloneDocker = collect($server->standaloneDockers->all());
|
||||
$swarmDocker = collect($server->swarmDockers->all());
|
||||
return $standaloneDocker->concat($swarmDocker);
|
||||
} else {
|
||||
$servers = Server::where('team_id', session('currentTeam')->id)->get();
|
||||
$standaloneDocker = $servers->map(function ($server) {
|
||||
return $server->standaloneDockers;
|
||||
})->flatten();
|
||||
$swarmDocker = $servers->map(function ($server) {
|
||||
return $server->swarmDockers;
|
||||
})->flatten();
|
||||
return $standaloneDocker->concat($swarmDocker);
|
||||
}
|
||||
$server = Server::ownedByCurrentTeam()->get()->where('id', $server_id)->firstOrFail();
|
||||
$standaloneDocker = collect($server->standaloneDockers->all());
|
||||
$swarmDocker = collect($server->swarmDockers->all());
|
||||
return $standaloneDocker->concat($swarmDocker);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class User extends Authenticatable
|
||||
$model->uuid = (string) new Cuid2(7);
|
||||
});
|
||||
}
|
||||
public function isPartOfRootTeam()
|
||||
public function isAdmin()
|
||||
{
|
||||
$found_root_team = auth()->user()->teams->filter(function ($team) {
|
||||
if ($team->id == 0) {
|
||||
|
||||
Reference in New Issue
Block a user