# 自定义路由模型绑定

要手动配置路由模型绑定,请在App\Providers\RouteServiceProvider的boot方法中添加一行

{% code title="Example 3-33. Adding a route model binding" %}

```php
public function boot() {
    // Just allows the parent's boot() method to still run
    parent::boot();
    // Perform the binding
    Route::model('event', Conference::class);
}
```

{% endcode %}

您现在已经指定，只要路由在其定义中具有名为{event}的参数，如示例3-34所示，路由解析器将返回具有该URL参数的ID的Conference类的实例

{% code title="Example 3-34. Using an explicit route model binding" %}

```php
Route::get('events/{event}', function (Conference $event) { 
    return view('events.show')->with('event', $event);
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/lu-you-yu-kong-zhi-qi/lu-you-mo-xing-bang-ding/zi-ding-yi-lu-you-mo-xing-bang-ding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
