mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-24 08:29:37 +00:00
Add model-level hidden fields for secrets, tokens, keys, notification credentials, deployment logs, and environment values. Allow explicit read:sensitive API access to reveal gated private keys and deployment logs, and cover the behavior with feature and unit tests.
49 lines
921 B
PHP
49 lines
921 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class CloudProviderToken extends BaseModel
|
|
{
|
|
protected $fillable = [
|
|
'team_id',
|
|
'provider',
|
|
'token',
|
|
'name',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'token',
|
|
];
|
|
|
|
protected $casts = [
|
|
'token' => 'encrypted',
|
|
];
|
|
|
|
public function team()
|
|
{
|
|
return $this->belongsTo(Team::class);
|
|
}
|
|
|
|
public function servers()
|
|
{
|
|
return $this->hasMany(Server::class);
|
|
}
|
|
|
|
public function hasServers(): bool
|
|
{
|
|
return $this->servers()->exists();
|
|
}
|
|
|
|
public static function ownedByCurrentTeam(array $select = ['*'])
|
|
{
|
|
$selectArray = collect($select)->concat(['id']);
|
|
|
|
return self::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
|
}
|
|
|
|
public function scopeForProvider($query, string $provider)
|
|
{
|
|
return $query->where('provider', $provider);
|
|
}
|
|
}
|