*/ use HasFactory; use SoftDeletes; protected $fillable = [ 'user_id', 'name', 'public_key', ]; protected $casts = [ 'user_id' => 'integer', 'public_key' => 'encrypted', ]; /** * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * @return BelongsToMany */ public function servers(): BelongsToMany { return $this->belongsToMany(Server::class, 'server_ssh_keys') ->withPivot('status') ->withTimestamps(); } public function existsOnServer(Server $server): bool { return (bool) $this->servers()->where('id', $server->id)->first(); } }