[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/core](../../README) / [index](../README) / RouteRegistration

# Interface: RouteRegistration

Defined in: [router/Router.ts:237](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/router/Router.ts#L237)

Returned by Router.get/post/put/delete/patch — allows chaining .name() and .bind()
to register the route for URL generation and model binding.

## Example

```ts
Router.get('/posts/:slug', PostController, 'show').name('posts.show');
route('posts.show', { slug: 'hello' }); // → '/posts/hello'

Router.get('/users/:user', UserController, 'show').bind('user', User);
// controller: const user = ctx.model<User>('user');
```

## Methods

### name()

> **name**(`routeName`): `RouteRegistration`

Defined in: [router/Router.ts:243](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/router/Router.ts#L243)

Name this route so it can be resolved to a URL with the [route](../functions/route) helper.

#### Parameters

##### routeName

`string`

Dot-notation name, e.g. `'posts.show'`.

#### Returns

`RouteRegistration`

***

### bind()

> **bind**(`paramName`, `model`): `RouteRegistration`

Defined in: [router/Router.ts:263](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/router/Router.ts#L263)

Attach a model binding to a specific route parameter.

When a request matches this route, the framework calls `Model.findOrFail(id)`
before the controller runs and stores the result in `ctx.model('paramName')`.
If the record does not exist, a `ModelNotFoundError` (404) is thrown automatically.

#### Parameters

##### paramName

`string`

The `:param` segment name (without the colon).

##### model

[`ModelClass`](ModelClass) \| [`ModelBindingResolver`](../type-aliases/ModelBindingResolver)

A model class with a `static findOrFail(id)` method,
                  OR a custom async resolver `(value, ctx) => Promise<T>`.

#### Returns

`RouteRegistration`

#### Example

```ts
// Model class (uses findOrFail internally):
Router.get('/users/:user', UserController, 'show').bind('user', User);

// Custom resolver — resolve by slug instead of id:
Router.get('/posts/:post', PostController, 'show')
  .bind('post', (value) => Post.where('slug', value).firstOrFail());
```
