clusev/app/Models/SshCredential.php

31 lines
675 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class SshCredential extends Model
{
protected $guarded = [];
// Hidden from serialization; encrypted at rest via APP_KEY.
protected $hidden = ['secret', 'passphrase'];
protected $casts = [
'secret' => 'encrypted',
'passphrase' => 'encrypted',
];
protected static function booted(): void
{
static::creating(fn (self $c) => $c->uuid ??= (string) Str::uuid());
}
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
}