'int', 'backup_restore_id' => 'int', 'generation' => 'int', 'job_id' => 'int', 'reservation_id' => 'int', 'target_host_id' => 'int', 'target_network_attachment_id' => 'int', 'active_attempt' => 'int', 'effect_resolved_at' => 'int', 'terminal_at' => 'int', 'created_at' => 'int', 'updated_at' => 'int', ]; public function restore() { return $this->belongsTo(CloudBackupRestore::class, 'backup_restore_id'); } public function boundReservationQuery() { $reservationId = (int) ($this->reservation_id ?? 0); $attemptKey = (string) ($this->attempt_key ?? ''); if ($reservationId < 1 || preg_match('/^[a-f0-9]{32}$/D', $attemptKey) !== 1) { throw new \LogicException( 'Restore attempt reservation identity is incomplete.' ); } return CloudResourceReservation::query() ->where('id', $reservationId) ->where('backup_restore_attempt_key', $attemptKey); } public function job() { return $this->belongsTo(CloudJob::class, 'job_id'); } public function matchesReservation( CloudResourceReservation $reservation ): bool { $attemptKey = (string) ($this->attempt_key ?? ''); return (int) ($this->reservation_id ?? 0) > 0 && (int) $this->reservation_id === (int) ($reservation->id ?? 0) && preg_match('/^[a-f0-9]{32}$/D', $attemptKey) === 1 && hash_equals( $attemptKey, (string) ($reservation->backup_restore_attempt_key ?? '') ); } }