# with closure

Sometimes we do not need a controller to display a view we just need to define a callable parameter in our routes.

```php
Route::get('/home', function () {
    $pageTitle = "Home";
    return view('/home', compact('pageTitle'));
});
```

With this callable parameter we can do some logic in our routes or even query our database to fetch some data and then pass to our views.

We can also pass the route with a parameter and access it inside our callable parameter in our route.

```php
Route::get('/profile/detail/{id}', function ($id) {
   echo $id;
});
```


---

# 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://sprnva.gitbook.io/sprnva-docs/routing/with-closure.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.
