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.
37 lines
675 B
PHP
37 lines
675 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CloudInitScript extends Model
|
|
{
|
|
protected $fillable = [
|
|
'team_id',
|
|
'name',
|
|
'script',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'script',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'script' => 'encrypted',
|
|
];
|
|
}
|
|
|
|
public function team()
|
|
{
|
|
return $this->belongsTo(Team::class);
|
|
}
|
|
|
|
public static function ownedByCurrentTeam(array $select = ['*'])
|
|
{
|
|
$selectArray = collect($select)->concat(['id']);
|
|
|
|
return self::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
|
}
|
|
}
|