protected function bindWithKey(Model $entity, ?string $name): ?string
    {
        if (\is_null($name) || (\strpos($name, '{') === false && \strpos($name, '}') === false)) {
            return $name;
        }

        $id = $entity->getKey();

        if (! isset($this->data[$id])) {
            $data = \array_merge(Arr::dot(['entity' => $entity->toArray()]), \compact('id'));

            $this->data[$id] = $data;
        }

        return Str::replace($name, $this->data[$id]);
    }