'encrypted', ]; /** * Get the user that owns the database. */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get the decrypted database password. */ public function getDecryptedPasswordAttribute(): string { return decrypt($this->db_password); } /** * Set the encrypted database password. */ public function setPasswordAttribute(string $password): void { $this->attributes['db_password'] = encrypt($password); } public function scopeMine(Builder $query): Builder { $user = auth()->user(); return $query->when($user && !$user->isAdmin(), fn($query) => $query->where('user_id', $user->id)); } }